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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
499 B
Go
Raw Normal View History

package root
import (
"context"
"testing"
2025-03-06 12:02:55 +00:00
"github.com/databricks/cli/libs/command"
"github.com/databricks/databricks-sdk-go/useragent"
"github.com/stretchr/testify/assert"
)
func TestWithCommandExecIdInUserAgent(t *testing.T) {
2025-03-06 12:02:55 +00:00
ctx := command.MockExecId(context.Background(), "some-exec-id")
ctx = withCommandExecIdInUserAgent(ctx)
2025-03-06 12:02:55 +00:00
// Check that the command exec ID is set in the user agent string.
ua := useragent.FromContext(ctx)
2025-03-06 12:02:55 +00:00
assert.Contains(t, ua, "cmd-exec-id/some-exec-id")
}