github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/build/cleanup_test.go (about) 1 package build 2 3 import ( 4 "sync" 5 "testing" 6 7 "github.com/gobuffalo/envy" 8 "github.com/gobuffalo/genny/v2/gentest" 9 "github.com/gobuffalo/meta" 10 "github.com/stretchr/testify/require" 11 ) 12 13 func Test_WithDeps(t *testing.T) { 14 r := require.New(t) 15 envy.Set(envy.GO111MODULE, "on") 16 17 run := gentest.NewRunner() 18 19 opts := &Options{ 20 WithAssets: false, 21 WithBuildDeps: true, 22 Environment: "bar", 23 App: meta.New("."), 24 } 25 26 emptyMap := sync.Map{} 27 opts.rollback = &emptyMap 28 29 f := Cleanup(opts) 30 f(run) 31 32 results := run.Results() 33 34 cmds := []string{"go mod tidy"} 35 for i, c := range results.Commands { 36 eq(r, cmds[i], c) 37 } 38 } 39 40 func Test_WithoutDeps(t *testing.T) { 41 r := require.New(t) 42 envy.Set(envy.GO111MODULE, "on") 43 44 run := gentest.NewRunner() 45 46 opts := &Options{ 47 WithAssets: false, 48 WithBuildDeps: false, 49 Environment: "bar", 50 App: meta.New("."), 51 } 52 53 emptyMap := sync.Map{} 54 opts.rollback = &emptyMap 55 56 f := Cleanup(opts) 57 f(run) 58 59 results := run.Results() 60 61 r.Len(results.Commands, 0) 62 }