We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0769798 commit 2394028Copy full SHA for 2394028
internal/pkg/agent/cmd/cmd_test.go
@@ -6,6 +6,9 @@ package cmd
6
7
import (
8
"testing"
9
+
10
+ "github.com/spf13/cobra"
11
+ "github.com/stretchr/testify/require"
12
)
13
14
func TestAgent(t *testing.T) {
@@ -30,3 +33,18 @@ func TestAgent(t *testing.T) {
30
33
// assert.True(t, strings.Contains(string(contents), "Hello I am running"))
31
34
// })
32
35
}
36
37
+func TestAddCommandIfNotNil(t *testing.T) {
38
+ cmd := &cobra.Command{}
39
40
+ parent := &cobra.Command{}
41
+ addCommandIfNotNil(parent, cmd)
42
+ require.Equal(t, 1, len(parent.Commands()))
43
44
+ parent = &cobra.Command{}
45
+ addCommandIfNotNil(parent, nil)
46
+ require.Equal(t, 0, len(parent.Commands()))
47
48
+ // this should not panic
49
+ addCommandIfNotNil(nil, cmd)
50
+}
0 commit comments