github.com/JarrahG/buffalocli@v0.0.0-20230801092127-b85bfd5d395a/internal/genny/add/add_test.go (about) 1 package add 2 3 import ( 4 "bytes" 5 "go/build" 6 "path/filepath" 7 "strings" 8 "testing" 9 10 "github.com/JarrahG/buffalocli/internal/plugins/plugdeps" 11 "github.com/gobuffalo/genny/v2" 12 "github.com/gobuffalo/genny/v2/gentest" 13 "github.com/gobuffalo/meta" 14 "github.com/stretchr/testify/require" 15 ) 16 17 func Test_New(t *testing.T) { 18 r := require.New(t) 19 20 g, err := New(&Options{ 21 App: meta.New("."), 22 Plugins: []plugdeps.Plugin{ 23 {Binary: "buffalo-pop", GoGet: "github.com/gobuffalo/buffalo-pop/v3@latest"}, 24 {Binary: "buffalo-hello.rb", Local: "./plugins/buffalo-hello.rb"}, 25 }, 26 }) 27 r.NoError(err) 28 29 run := gentest.NewRunner() 30 c := build.Default 31 run.Disk.Add(genny.NewFile(filepath.Join(c.GOPATH, "bin", "buffalo-pop"), &bytes.Buffer{})) 32 r.NoError(run.With(g)) 33 34 r.NoError(run.Run()) 35 36 res := run.Results() 37 38 ecmds := []string{} 39 r.Len(res.Commands, len(ecmds)) 40 for i, c := range res.Commands { 41 r.Equal(ecmds[i], strings.Join(c.Args, " ")) 42 } 43 44 efiles := []string{"bin/buffalo-pop", "config/buffalo-plugins.toml"} 45 r.Len(res.Files, len(efiles)) 46 for i, f := range res.Files { 47 r.True(strings.HasSuffix(f.Name(), efiles[i])) 48 } 49 }