Skip to content

Commit

Permalink
one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
michalpristas committed Jun 20, 2024
1 parent 0769798 commit 2394028
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/pkg/agent/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ package cmd

import (
"testing"

"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
)

func TestAgent(t *testing.T) {
Expand All @@ -30,3 +33,18 @@ func TestAgent(t *testing.T) {
// assert.True(t, strings.Contains(string(contents), "Hello I am running"))
// })
}

func TestAddCommandIfNotNil(t *testing.T) {
cmd := &cobra.Command{}

parent := &cobra.Command{}
addCommandIfNotNil(parent, cmd)
require.Equal(t, 1, len(parent.Commands()))

parent = &cobra.Command{}
addCommandIfNotNil(parent, nil)
require.Equal(t, 0, len(parent.Commands()))

// this should not panic
addCommandIfNotNil(nil, cmd)
}

0 comments on commit 2394028

Please sign in to comment.