github.com/lineaje-labs/syft@v0.98.1-0.20231227153149-9e393f60ff1b/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  			},
    18  		},
    19  	}
    20  
    21  	for _, test := range tests {
    22  		t.Run(test.name, func(t *testing.T) {
    23  			pkgCmd, pkgsStdout, pkgsStderr := runSyft(t, test.env, "version")
    24  			for _, traitFn := range test.assertions {
    25  				traitFn(t, pkgsStdout, pkgsStderr, pkgCmd.ProcessState.ExitCode())
    26  			}
    27  		})
    28  	}
    29  }