Skip to content

Commit

Permalink
fix: Use testhelpers to configure Datadog (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhhagen authored Dec 17, 2024
1 parent b1ff599 commit 60627df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 2 additions & 6 deletions bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/coopnorge/go-datadog-lib/v2/internal"
"github.com/coopnorge/go-datadog-lib/v2/internal/testhelpers"
"github.com/stretchr/testify/assert"
)

Expand All @@ -22,12 +23,7 @@ func TestBootstrapDatadogDisabled(t *testing.T) {
}

func TestBootstrap(t *testing.T) {
t.Setenv(internal.DatadogDisable, "false")
t.Setenv(internal.DatadogAPMEndpoint, "/tmp")
t.Setenv(internal.DatadogDSDEndpoint, "unix:///tmp/")
t.Setenv(internal.DatadogEnvironment, "unittest")
t.Setenv(internal.DatadogService, "go-datadog-lib-unit-test")
t.Setenv(internal.DatadogVersion, "42345kjh435")
testhelpers.ConfigureDatadog(t)

stop, err := Start(context.Background())
defer func() {
Expand Down
3 changes: 3 additions & 0 deletions internal/testhelpers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ import (

// ConfigureDatadog prepares the environment for running tests
func ConfigureDatadog(t *testing.T) {
t.Setenv(internal.DatadogDisable, "false")
t.Setenv(internal.DatadogEnvironment, "unittest")
t.Setenv(internal.DatadogService, "unittest-service")
t.Setenv(internal.DatadogVersion, "v0.0.0")
t.Setenv(internal.DatadogAPMEndpoint, "/dev/null")
t.Setenv(internal.DatadogDSDEndpoint, "unix:///dev/null")

// Called to ensure backwards compatibility
cfg := config.LoadDatadogConfigFromEnvVars()
err := cfg.Validate()
assert.NoError(t, err)
Expand Down

0 comments on commit 60627df

Please sign in to comment.