Skip to content

Commit

Permalink
move config testing into config package
Browse files Browse the repository at this point in the history
Sets the stage for being able to write tests for private functions.
  • Loading branch information
robbkidd committed Oct 11, 2023
1 parent af6b92b commit d09c6e4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package config_test
package config

import (
"os"
"testing"

"github.com/honeycombio/honeycomb-network-agent/config"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -38,7 +37,7 @@ func TestAPIMask(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
config := config.Config{
config := Config{
APIKey: tc.apiKey,
}

Expand All @@ -64,7 +63,7 @@ func TestEnvVars(t *testing.T) {
t.Setenv("ADDITIONAL_ATTRIBUTES", "key1=value1,key2=value2")
t.Setenv("INCLUDE_REQUEST_URL", "true")

config := config.NewConfig()
config := NewConfig()
assert.Equal(t, "1234567890123456789012", config.APIKey)
assert.Equal(t, "https://api.example.com", config.Endpoint)
assert.Equal(t, "test-dataset", config.Dataset)
Expand All @@ -88,7 +87,7 @@ func TestEnvVarsDefault(t *testing.T) {
// all the env vars in an array
os.Clearenv()

config := config.NewConfig()
config := NewConfig()
assert.Equal(t, "", config.APIKey)
assert.Equal(t, "https://api.honeycomb.io", config.Endpoint)
assert.Equal(t, "hny-network-agent", config.Dataset)
Expand Down

0 comments on commit d09c6e4

Please sign in to comment.