Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-bradley committed Jan 22, 2025
1 parent 9a79c99 commit aa570f5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions service/telemetry/internal/otelinit/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ func TestMetricReader(t *testing.T) {
},
wantErr: errors.New("unsupported protocol http/invalid"),
},
{
name: "periodic/otlp-exporter-nil-protocol",
reader: config.MetricReader{
Periodic: &config.PeriodicMetricReader{
Exporter: config.PushMetricExporter{
OTLP: &config.OTLPMetric{
Protocol: nil,
},
},
},
},
wantErr: errors.New("OTLP protocol not set"),
},
{
name: "periodic/otlp-grpc-exporter-no-endpoint",
reader: config.MetricReader{
Expand Down Expand Up @@ -574,3 +587,16 @@ func TestMetricReader(t *testing.T) {
})
}
}

func TestHeadersToMap(t *testing.T) {
pairs := []config.NameStringValuePair{
{Name: "zero", Value: strPtr("zeroValue")},
{Name: "one", Value: strPtr("oneValue")},
{Name: "nil", Value: nil},
}

m := convertHeadersToMap(pairs)
_, ok := m["nil"]
assert.False(t, ok)
assert.Len(t, m, 2)
}

0 comments on commit aa570f5

Please sign in to comment.