Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhihan-Li committed Sep 6, 2024
1 parent 59041d3 commit 6097f95
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 80 deletions.
78 changes: 39 additions & 39 deletions exporters/otlp/otlplog/otlploggrpc/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,47 +332,47 @@ func TestNewConfig(t *testing.T) {
`invalid OTEL_EXPORTER_OTLP_LOGS_TIMEOUT value 100 seconds: strconv.Atoi: parsing "100 seconds": invalid syntax`,
},
},
{
name: "HeadersWithSpaces",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": " keyWithSpaces =value1",
},
want: config{
headers: newSetting(map[string]string{
"keyWithSpaces": "value1",
}),
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
},
{
name: "HeadersWithPercentEncoding",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": "percent%20encoded=value,normal=ok",
},
want: config{
headers: newSetting(map[string]string{
"percent%20encoded": "value",
"normal": "ok",
}),
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
},
name: "HeadersWithSpaces",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": " keyWithSpaces =value1",
},
want: config{
headers: newSetting(map[string]string{
"keyWithSpaces": "value1",
}),
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
},
{
name: "HeadersWithInvalidKey",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": "valid=ok,inva lid=not_ok,also_valid=fine",
},
want: config{
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
errs: []string{`invalid header key: inva lid`},
},
name: "HeadersWithPercentEncoding",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": "percent%20encoded=value,normal=ok",
},
want: config{
headers: newSetting(map[string]string{
"percent%20encoded": "value",
"normal": "ok",
}),
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
},
{
name: "HeadersWithInvalidKey",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": "valid=ok,inva lid=not_ok,also_valid=fine",
},
want: config{
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
errs: []string{`invalid header key: inva lid`},
},
}

for _, tc := range testcases {
Expand Down
79 changes: 38 additions & 41 deletions exporters/otlp/otlplog/otlploghttp/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,49 +338,46 @@ func TestNewConfig(t *testing.T) {
},
},
{
name: "HeadersWithSpaces",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": " keyWithSpaces =value1",
},
want: config{
headers: newSetting(map[string]string{
"keyWithSpaces": "value1",
}),
endpoint: newSetting(defaultEndpoint),
path: newSetting(defaultPath),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
},
name: "HeadersWithSpaces",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": " keyWithSpaces =value1",
},
want: config{
headers: newSetting(map[string]string{
"keyWithSpaces": "value1",
}),
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
},
{
name: "HeadersWithPercentEncoding",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": "percent%20encoded=value,normal=ok",
},
want: config{
headers: newSetting(map[string]string{
"percent%20encoded": "value",
"normal": "ok",
}),
endpoint: newSetting(defaultEndpoint),
path: newSetting(defaultPath),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
},
name: "HeadersWithPercentEncoding",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": "percent%20encoded=value,normal=ok",
},
want: config{
headers: newSetting(map[string]string{
"percent%20encoded": "value",
"normal": "ok",
}),
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
},
{
name: "HeadersWithInvalidKey",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": "valid=ok,inva lid=not_ok,also_valid=fine",
},
want: config{
endpoint: newSetting(defaultEndpoint),
path: newSetting(defaultPath),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
errs: []string{`invalid header key: inva lid`},
},
name: "HeadersWithInvalidKey",
envars: map[string]string{
"OTEL_EXPORTER_OTLP_HEADERS": "valid=ok,inva lid=not_ok,also_valid=fine",
},
want: config{
endpoint: newSetting(defaultEndpoint),
timeout: newSetting(defaultTimeout),
retryCfg: newSetting(defaultRetryCfg),
},
errs: []string{`invalid header key: inva lid`},
},
}

for _, tc := range testcases {
Expand Down

0 comments on commit 6097f95

Please sign in to comment.