Skip to content

Commit

Permalink
transitioned to standard testing format from Convey testing format
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissimpkins committed Jan 5, 2018
1 parent 51b8791 commit 518f80c
Showing 1 changed file with 24 additions and 61 deletions.
85 changes: 24 additions & 61 deletions uni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"regexp"
"strings"
"testing"

. "github.com/smartystreets/goconvey/convey"
)

// test single argument requests to unicodeSearch function
Expand Down Expand Up @@ -102,82 +100,47 @@ func TestMainFunction(t *testing.T) {
}

func TestStdinValidatesTrueFunction(t *testing.T) {
file, _ := ioutil.TempFile(os.TempDir(), "stdin")
defer os.Remove(file.Name())

Convey("Test StdinValidates Function", t, func() {

Convey("Given mocked os.Stdin that should validate true", func() {
// Create temporary file
file, _ := ioutil.TempFile(os.TempDir(), "stdin")
defer os.Remove(file.Name())

// Write to it
file.WriteString("stdin test")
file.WriteString("stdin test")

Convey("Does mock stdin validate true?", func() {
So(stdinValidates(file), ShouldEqual, true)
})
})
result := stdinValidates(file)
if result != true {
t.Errorf("[FAIL] Attempt to validate mocked stdin failed.")
}

})
}

func TestStdinValidatesFalseFunction(t *testing.T) {
file, _ := ioutil.TempFile(os.TempDir(), "stdin")
defer os.Remove(file.Name())

Convey("Test StdinValidates Function", t, func() {

Convey("Given mocked os.Stdin that should validate false", func() {
// Create temporary file
file, _ := ioutil.TempFile(os.TempDir(), "stdin")
defer os.Remove(file.Name())
file.WriteString("")

// Write to it
file.WriteString("")

Convey("Does mock stdin validate false?", func() {
So(stdinValidates(file), ShouldEqual, false)
})
})
result := stdinValidates(file)
if result != false {
t.Errorf("[FAIL] Attempt to validate empty mocked stdin failed.")
}

})
}

func TestVersionString(t *testing.T) {
r, _ := regexp.Compile(`\d{1,2}.\d{1,2}.\d{1,2}`)

Convey("Version string formatting", t, func() {

Convey("Given the version string constant", func() {
v := version

Convey("Is the version string properly formatted", func() {
So(r.MatchString(v), ShouldEqual, true)
})
})
})
// match expected format of version string
if r.MatchString(version) != true {
t.Errorf("[FAIL] Unexpected version string format identified.")
}
}

func TestUsageString(t *testing.T) {
Convey("Usage string formatting", t, func() {

Convey("Given the usage string constant", func() {
u := usage

Convey("Does the usage string have an appropriate start substring?", func() {
So(u, ShouldStartWith, "Usage:")
})
})
})
if strings.HasPrefix(usage, "Usage:") == false {
t.Errorf("[FAIL] Unexpected usage string format.")
}
}

func TestHelpString(t *testing.T) {
Convey("Help string formatting", t, func() {

Convey("Given the help string constant", func() {
h := help

Convey("Does the usage string have an appropriate start substring?", func() {
So(h, ShouldStartWith, "=======")
})
})
})
if strings.HasPrefix(help, "=====") == false {
t.Errorf("[FAIL] Unexpected help string format.")
}
}

0 comments on commit 518f80c

Please sign in to comment.