databricks-cli/cmd/root/user_agent_command_test.go

30 lines
477 B
Go

package root
import (
"testing"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
)
func TestCommandString(t *testing.T) {
root := &cobra.Command{
Use: "root",
}
hello := &cobra.Command{
Use: "hello",
}
world := &cobra.Command{
Use: "world",
}
root.AddCommand(hello)
hello.AddCommand(world)
assert.Equal(t, "root", commandString(root))
assert.Equal(t, "hello", commandString(hello))
assert.Equal(t, "hello_world", commandString(world))
}