mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +00:00
chore: improve cli version command and add tests (#8336)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
3967adde6e
commit
67cfa341a5
2 changed files with 21 additions and 0 deletions
|
@ -14,6 +14,7 @@ func Command() *cobra.Command {
|
||||||
Short: command.FormatDescription(true, websiteUrl, false, description...),
|
Short: command.FormatDescription(true, websiteUrl, false, description...),
|
||||||
Long: command.FormatDescription(false, websiteUrl, false, description...),
|
Long: command.FormatDescription(false, websiteUrl, false, description...),
|
||||||
Example: command.FormatExamples(examples...),
|
Example: command.FormatExamples(examples...),
|
||||||
|
Args: cobra.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
fmt.Printf("Version: %s\n", version.Version())
|
fmt.Printf("Version: %s\n", version.Version())
|
||||||
fmt.Printf("Time: %s\n", version.Time())
|
fmt.Printf("Time: %s\n", version.Time())
|
||||||
|
|
20
cmd/cli/kubectl-kyverno/commands/version/command_test.go
Normal file
20
cmd/cli/kubectl-kyverno/commands/version/command_test.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCommand(t *testing.T) {
|
||||||
|
cmd := Command()
|
||||||
|
err := cmd.Execute()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCommandWithArgs(t *testing.T) {
|
||||||
|
cmd := Command()
|
||||||
|
cmd.SetArgs([]string{"test"})
|
||||||
|
err := cmd.Execute()
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
Loading…
Reference in a new issue