Skip to content

Commit

Permalink
[exporter/honeycombmarker] Update tests (#30399)
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth authored Jan 10, 2024
1 parent 354d531 commit 5e1865f
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions exporter/honeycombmarkerexporter/logs_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (

func TestExportMarkers(t *testing.T) {
tests := []struct {
name string
config Config
attributeMap map[string]string
expectedURL string
name string
config Config
attributeMap map[string]string
expectedAPIKey string
expectedURL string
}{
{
name: "all fields",
Expand All @@ -48,7 +49,8 @@ func TestExportMarkers(t *testing.T) {
"url": "https://api.testhost.io",
"type": "test-type",
},
expectedURL: "/1/markers/test-dataset",
expectedAPIKey: "test-apikey",
expectedURL: "/1/markers/test-dataset",
},
{
name: "no message key",
Expand All @@ -71,7 +73,8 @@ func TestExportMarkers(t *testing.T) {
"url": "https://api.testhost.io",
"type": "test-type",
},
expectedURL: "/1/markers/test-dataset",
expectedAPIKey: "test-apikey",
expectedURL: "/1/markers/test-dataset",
},
{
name: "no url",
Expand All @@ -94,7 +97,8 @@ func TestExportMarkers(t *testing.T) {
"message": "this is a test message",
"type": "test-type",
},
expectedURL: "/1/markers/test-dataset",
expectedAPIKey: "test-apikey",
expectedURL: "/1/markers/test-dataset",
},
{
name: "no dataset_slug",
Expand All @@ -114,7 +118,8 @@ func TestExportMarkers(t *testing.T) {
attributeMap: map[string]string{
"type": "test-type",
},
expectedURL: "/1/markers/__all__",
expectedAPIKey: "test-apikey",
expectedURL: "/1/markers/__all__",
},
}

Expand All @@ -126,15 +131,15 @@ func TestExportMarkers(t *testing.T) {

require.NoError(t, err)

assert.Equal(t, len(decodedBody), len(tt.attributeMap))
assert.Equal(t, len(tt.attributeMap), len(decodedBody))

for attr := range tt.attributeMap {
assert.Equal(t, decodedBody[attr], tt.attributeMap[attr])
assert.Equal(t, tt.attributeMap[attr], decodedBody[attr])
}
assert.Contains(t, req.URL.Path, tt.expectedURL)

apiKey := req.Header.Get(honeycombTeam)
assert.Equal(t, apiKey, string(tt.config.APIKey))
assert.Equal(t, tt.expectedAPIKey, apiKey)

userAgent := req.Header.Get(userAgentHeaderKey)
assert.NotEmpty(t, userAgent)
Expand Down

0 comments on commit 5e1865f

Please sign in to comment.