github.com/gobuffalo/buffalo-cli/v2@v2.0.0-alpha.15.0.20200919213536-a7350c8e6799/cli/cmds/version/cmd_test.go (about) 1 package version 2 3 import ( 4 "bytes" 5 "context" 6 "fmt" 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 ) 11 12 func Test_Cmd(t *testing.T) { 13 r := require.New(t) 14 15 vc := &Cmd{} 16 17 bb := &bytes.Buffer{} 18 vc.SetStdout(bb) 19 20 ctx := context.Background() 21 22 args := []string{} 23 24 err := vc.Main(ctx, ".", args) 25 r.NoError(err) 26 27 r.Contains(bb.String(), Version) 28 } 29 30 func Test_Cmd_JSON(t *testing.T) { 31 r := require.New(t) 32 33 vc := &Cmd{} 34 35 bb := &bytes.Buffer{} 36 vc.SetStdout(bb) 37 38 ctx := context.Background() 39 40 args := []string{"--json"} 41 42 err := vc.Main(ctx, ".", args) 43 r.NoError(err) 44 45 r.Contains(bb.String(), fmt.Sprintf("%q: %q", "version", Version)) 46 }