github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/plugins/plugdeps/plugins_test.go (about) 1 package plugdeps 2 3 import ( 4 "bytes" 5 "fmt" 6 "strings" 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 ) 11 12 func Test_Plugins_Encode(t *testing.T) { 13 r := require.New(t) 14 15 bb := &bytes.Buffer{} 16 17 plugs := New() 18 plugs.Add(pop, heroku, local) 19 20 r.NoError(plugs.Encode(bb)) 21 22 fmt.Println(bb.String()) 23 act := strings.TrimSpace(bb.String()) 24 exp := strings.TrimSpace(eToml) 25 r.Equal(exp, act) 26 } 27 28 func Test_Plugins_Decode(t *testing.T) { 29 r := require.New(t) 30 31 plugs := New() 32 r.NoError(plugs.Decode(strings.NewReader(eToml))) 33 34 names := []string{"buffalo-hello.rb", "buffalo-heroku", "buffalo-pop"} 35 list := plugs.List() 36 37 r.Len(list, len(names)) 38 for i, p := range list { 39 r.Equal(names[i], p.Binary) 40 } 41 } 42 43 func Test_Plugins_Remove(t *testing.T) { 44 r := require.New(t) 45 46 plugs := New() 47 plugs.Add(pop, heroku) 48 r.Len(plugs.List(), 2) 49 plugs.Remove(pop) 50 r.Len(plugs.List(), 1) 51 }