Skip to content

Commit

Permalink
Fix coverage issues for invalid url paths
Browse files Browse the repository at this point in the history
  • Loading branch information
fredthomsen committed Jun 29, 2023
1 parent e5df180 commit c8ed288
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
32 changes: 27 additions & 5 deletions receiver/otlpreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,33 @@ func TestUnmarshalConfigEmptyProtocols(t *testing.T) {
}

func TestUnmarshalConfigInvalidSignalPath(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "invalid_signal_path.yaml"))
require.NoError(t, err)
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
assert.EqualError(t, component.UnmarshalConfig(cm, cfg), "invalid HTTP URL path set for signal: parse \":invalid\": missing protocol scheme")
tests := []struct {
name string
testDataFn string
}{
{
name: "Invalid traces URL path",
testDataFn: "invalid_traces_path.yaml",
},
{
name: "Invalid metrics URL path",
testDataFn: "invalid_metrics_path.yaml",
},
{
name: "Invalid logs URL path",
testDataFn: "invalid_logs_path.yaml",
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", test.testDataFn))
require.NoError(t, err)
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
assert.EqualError(t, component.UnmarshalConfig(cm, cfg), "invalid HTTP URL path set for signal: parse \":invalid\": missing protocol scheme")
})
}
}

func TestUnmarshalConfigEmpty(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions receiver/otlpreceiver/testdata/invalid_logs_path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
protocols:
http:
logs_url_path: ":invalid"
3 changes: 3 additions & 0 deletions receiver/otlpreceiver/testdata/invalid_traces_path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
protocols:
http:
traces_url_path: ":invalid"

0 comments on commit c8ed288

Please sign in to comment.