github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/test/cli/version_cmd_test.go (about) 1 package cli 2 3 import ( 4 "testing" 5 ) 6 7 func TestVersionCmdPrintsToStdout(t *testing.T) { 8 tests := []struct { 9 name string 10 env map[string]string 11 assertions []traitAssertion 12 }{ 13 { 14 name: "version command prints to stdout", 15 assertions: []traitAssertion{ 16 assertInOutput("Version:"), 17 assertNoStderr, 18 }, 19 }, 20 } 21 22 for _, test := range tests { 23 t.Run(test.name, func(t *testing.T) { 24 pkgCmd, pkgsStdout, pkgsStderr := runSyft(t, test.env, "version") 25 for _, traitFn := range test.assertions { 26 traitFn(t, pkgsStdout, pkgsStderr, pkgCmd.ProcessState.ExitCode()) 27 } 28 }) 29 } 30 }