mirror of
https://github.com/kubescape/kubescape.git
synced 2026-02-14 18:09:55 +00:00
Wrote new tests for the following packages - operator - patch - scan Also fixed potential crash in the RunE function of the image subcommand in the scan package. Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
33 lines
905 B
Go
33 lines
905 B
Go
package operator
|
|
|
|
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 TestGetOperatorScanConfigCmd(t *testing.T) {
|
|
// Create a mock Kubescape interface
|
|
mockKubescape := &mocks.MockIKubescape{}
|
|
operatorInfo := cautils.OperatorInfo{
|
|
Namespace: "namespace",
|
|
}
|
|
|
|
cmd := getOperatorScanConfigCmd(mockKubescape, operatorInfo)
|
|
|
|
// Verify the command name and short description
|
|
assert.Equal(t, "configurations", cmd.Use)
|
|
assert.Equal(t, "Trigger configuration scanning from the Kubescape Operator microservice", cmd.Short)
|
|
assert.Equal(t, "", cmd.Long)
|
|
assert.Equal(t, operatorScanConfigExamples, cmd.Example)
|
|
|
|
err := cmd.Args(&cobra.Command{}, []string{})
|
|
assert.Nil(t, err)
|
|
|
|
err = cmd.Args(&cobra.Command{}, []string{"configurations"})
|
|
assert.Nil(t, err)
|
|
}
|