Skip to content

Commit

Permalink
add test for nil name as well
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten committed Dec 11, 2024
1 parent 26a44a0 commit 803760b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
49 changes: 49 additions & 0 deletions config/testdata/invalid_nil_name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"file_format": "0.3",
"disabled": false,
"logger_provider": {
"processors": [
{
"batch": {
"schedule_delay": 5000,
"export_timeout": 30000,
"max_queue_size": 2048,
"max_export_batch_size": 512,
"exporter": {
"otlp": {
"protocol": "http/protobuf",
"endpoint": "http://localhost:4318/v1/logs",
"certificate": "/app/cert.pem",
"client_key": "/app/cert.pem",
"client_certificate": "/app/cert.pem",
"headers": [
{
"name": "api-key",
"value": "1234"
},
{
"value": "nil-name"
}
],
"headers_list": "api-key=1234",
"compression": "gzip",
"timeout": 10000,
"insecure": false
}
}
}
},
{
"simple": {
"exporter": {
"console": {}
}
}
}
],
"limits": {
"attribute_value_length_limit": 4096,
"attribute_count_limit": 128
}
}
}
13 changes: 13 additions & 0 deletions config/testdata/invalid_nil_name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
file_format: "0.3"
disabled: false
logger_provider:
processors:
- batch:
exporter:
otlp:
protocol: http/protobuf
endpoint: http://localhost:4318/v1/logs
headers:
- name: api-key
value: "1234"
- value: nil-name
10 changes: 10 additions & 0 deletions config/v0.3.0/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ func TestParseYAML(t *testing.T) {
wantErr: errors.New(`yaml: unmarshal errors:
line 2: cannot unmarshal !!str ` + "`notabool`" + ` into bool`),
},
{
name: "invalid nil name",
input: "invalid_nil_name.yaml",
wantErr: errors.New(`yaml: cannot unmarshal field name in NameStringValuePair required`),
},
{
name: "invalid nil value",
input: "invalid_nil_value.yaml",
Expand Down Expand Up @@ -465,6 +470,11 @@ func TestSerializeJSON(t *testing.T) {
input: "invalid_bool.json",
wantErr: errors.New(`json: cannot unmarshal string into Go struct field Plain.disabled of type bool`),
},
{
name: "invalid nil name",
input: "invalid_nil_name.json",
wantErr: errors.New(`json: cannot unmarshal field name in NameStringValuePair required`),
},
{
name: "invalid nil value",
input: "invalid_nil_value.json",
Expand Down

0 comments on commit 803760b

Please sign in to comment.