databricks-cli/cmd/root/user_agent_command_exec_id_...

20 lines
514 B
Go

package root
import (
"context"
"testing"
"github.com/databricks/cli/libs/command"
"github.com/databricks/databricks-sdk-go/useragent"
"github.com/stretchr/testify/assert"
)
func TestWithCommandExecIdInUserAgent(t *testing.T) {
ctx := command.GenerateExecId(context.Background())
ctx = withCommandExecIdInUserAgent(ctx)
// user agent should contain cmd-exec-id/<UUID>
ua := useragent.FromContext(ctx)
assert.Regexp(t, `cmd-exec-id/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`, ua)
}