Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI Visibility] Add support for CI Visibility mode in ddtrace #2739

13 changes: 8 additions & 5 deletions ddtrace/tracer/civisibility_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
)

func TestCiVisibilityTransport(t *testing.T) {
t.Run("agentless", func(t *testing.T) { runTransportTest(t, true) })
t.Run("agentbased", func(t *testing.T) { runTransportTest(t, false) })
t.Run("agentless", func(t *testing.T) { runTransportTest(t, true, true) })
t.Run("agentless_no_api_key", func(t *testing.T) { runTransportTest(t, true, false) })
t.Run("agentbased", func(t *testing.T) { runTransportTest(t, false, true) })
}

func runTransportTest(t *testing.T, agentless bool) {
func runTransportTest(t *testing.T, agentless, shouldSetAPIKey bool) {
assert := assert.New(t)

testCases := []struct {
Expand All @@ -42,7 +43,7 @@ func runTransportTest(t *testing.T, agentless bool) {
metaLang := r.Header.Get("Datadog-Meta-Lang")
assert.NotNil(metaLang)

if agentless {
if agentless && shouldSetAPIKey {
apikey := r.Header.Get("dd-api-key")
assert.Equal("12345", apikey)
}
Expand Down Expand Up @@ -87,7 +88,9 @@ func runTransportTest(t *testing.T, agentless bool) {
if agentless {
t.Setenv(constants.CIVisibilityAgentlessEnabledEnvironmentVariable, "1")
t.Setenv(constants.CIVisibilityAgentlessURLEnvironmentVariable, srv.URL)
t.Setenv(constants.APIKeyEnvironmentVariable, "12345")
if shouldSetAPIKey {
t.Setenv(constants.APIKeyEnvironmentVariable, "12345")
}
dianashevchenko marked this conversation as resolved.
Show resolved Hide resolved
}

for _, tc := range testCases {
Expand Down
Loading