package scan import ( "testing" "github.com/kubescape/kubescape/v3/core/cautils" "github.com/kubescape/kubescape/v3/core/mocks" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" ) func TestGetImageCmd(t *testing.T) { // Create a mock Kubescape interface mockKubescape := &mocks.MockIKubescape{} scanInfo := cautils.ScanInfo{ AccountID: "new", } cmd := getImageCmd(mockKubescape, &scanInfo) // Verify the command name and short description assert.Equal(t, "image : [flags]", cmd.Use) assert.Equal(t, "Scan an image for vulnerabilities", cmd.Short) assert.Equal(t, imageExample, cmd.Example) err := cmd.Args(&cobra.Command{}, []string{}) expectedErrorMessage := "the command takes exactly one image name as an argument" assert.Equal(t, expectedErrorMessage, err.Error()) err = cmd.Args(&cobra.Command{}, []string{"nginx"}) assert.Nil(t, err) err = cmd.RunE(&cobra.Command{}, []string{}) assert.Equal(t, expectedErrorMessage, err.Error()) }