Skip to content

Commit

Permalink
fix(ddtrace/tracer): don't use my-host as hostname in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darccio committed Nov 28, 2024
1 parent 3b0a239 commit d478039
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ddtrace/tracer/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,13 @@ func TestTracerOptionsDefaults(t *testing.T) {
})

t.Run("env-host", func(t *testing.T) {
t.Setenv("DD_AGENT_HOST", "my-host")
t.Setenv("DD_AGENT_HOST", "127.0.0.1")
tracer, err := newTracer(opts...)
assert.NoError(t, err)
defer tracer.Stop()
c := tracer.config
assert.Equal(t, "my-host:8125", c.dogstatsdAddr)
assert.Equal(t, "my-host:8125", globalconfig.DogstatsdAddr())
assert.Equal(t, "127.0.0.1:8125", c.dogstatsdAddr)
assert.Equal(t, "127.0.0.1:8125", globalconfig.DogstatsdAddr())
})

t.Run("env-port", func(t *testing.T) {
Expand All @@ -603,26 +603,26 @@ func TestTracerOptionsDefaults(t *testing.T) {
})

t.Run("env-both", func(t *testing.T) {
t.Setenv("DD_AGENT_HOST", "my-host")
t.Setenv("DD_AGENT_HOST", "127.0.0.1")
t.Setenv("DD_DOGSTATSD_PORT", "123")
tracer, err := newTracer(opts...)
assert.NoError(t, err)
defer tracer.Stop()
c := tracer.config
assert.Equal(t, "my-host:8125", c.dogstatsdAddr)
assert.Equal(t, "my-host:8125", globalconfig.DogstatsdAddr())
assert.Equal(t, "127.0.0.1:8125", c.dogstatsdAddr)
assert.Equal(t, "127.0.0.1:8125", globalconfig.DogstatsdAddr())
})

t.Run("env-both: agent not available", func(t *testing.T) {
t.Setenv("DD_AGENT_HOST", "my-host")
t.Setenv("DD_AGENT_HOST", "127.0.0.1")
t.Setenv("DD_DOGSTATSD_PORT", "123")
fail = true
tracer, err := newTracer(opts...)
assert.NoError(t, err)
defer tracer.Stop()
c := tracer.config
assert.Equal(t, "my-host:123", c.dogstatsdAddr)
assert.Equal(t, "my-host:123", globalconfig.DogstatsdAddr())
assert.Equal(t, "127.0.0.1:123", c.dogstatsdAddr)
assert.Equal(t, "127.0.0.1:123", globalconfig.DogstatsdAddr())
fail = false
})

Expand Down

0 comments on commit d478039

Please sign in to comment.