forked from corbym/gogiven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator_test.go
36 lines (32 loc) · 984 Bytes
/
generator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package gogiven_test
import (
"github.com/corbym/gocrest/is"
"github.com/corbym/gocrest/then"
"github.com/corbym/gogiven"
"github.com/corbym/gogiven/testdata"
"os"
"testing"
)
func TestGenerateTestOutput(t *testing.T) {
defer func() {
remove := os.Remove(ofFileInTmpDir("generator_test.html"))
then.AssertThat(t, remove, is.Nil())
}()
t.Parallel()
gogiven.Given(t, func(givens testdata.InterestingGivens) {
})
gogiven.GenerateTestOutput()
then.AssertThat(t, fileExists(ofFileInTmpDir("generator_test.html")), inTmpDir())
}
func TestGenerateTestOutput_DefaultsToCurrentDir(t *testing.T) {
old := os.Getenv("GOGIVENS_OUTPUT_DIR")
defer func() {
remove := os.Remove("./generator_test.html")
then.AssertThat(t, remove, is.Nil())
}()
defer func() { os.Setenv("GOGIVENS_OUTPUT_DIR", old) }()
os.Setenv("GOGIVENS_OUTPUT_DIR", "doesnotexist")
gogiven.Given(t)
gogiven.GenerateTestOutput()
then.AssertThat(t, fileExists("./generator_test.html"), inTmpDir())
}