MCPcopy Index your code
hub / github.com/netdata/netdata / TestJSONParser_ReadLine

Function TestJSONParser_ReadLine

src/go/plugin/go.d/pkg/logs/json_test.go:43–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestJSONParser_ReadLine(t *testing.T) {
44 tests := map[string]struct {
45 config JSONConfig
46 input string
47 wantAssigned map[string]string
48 wantErr bool
49 }{
50 "string value": {
51 input: `{ "string": "example.com" }`,
52 wantErr: false,
53 wantAssigned: map[string]string{
54 "string": "example.com",
55 },
56 },
57 "int value": {
58 input: `{ "int": 1 }`,
59 wantErr: false,
60 wantAssigned: map[string]string{
61 "int": "1",
62 },
63 },
64 "float value": {
65 input: `{ "float": 1.1 }`,
66 wantErr: false,
67 wantAssigned: map[string]string{
68 "float": "1.1",
69 },
70 },
71 "string, int, float values": {
72 input: `{ "string": "example.com", "int": 1, "float": 1.1 }`,
73 wantErr: false,
74 wantAssigned: map[string]string{
75 "string": "example.com",
76 "int": "1",
77 "float": "1.1",
78 },
79 },
80 "string, int, float values with mappings": {
81 config: JSONConfig{Mapping: map[string]string{
82 "string": "STRING",
83 "int": "INT",
84 "float": "FLOAT",
85 }},
86 input: `{ "string": "example.com", "int": 1, "float": 1.1 }`,
87 wantErr: false,
88 wantAssigned: map[string]string{
89 "STRING": "example.com",
90 "INT": "1",
91 "FLOAT": "1.1",
92 },
93 },
94 "nested": {
95 input: `{"one":{"two":2,"three":{"four":4}},"five":5}`,
96 config: JSONConfig{Mapping: map[string]string{
97 "one.two": "mapped_value",
98 }},
99 wantErr: false,
100 wantAssigned: map[string]string{

Callers

nothing calls this directly

Calls 6

ReadLineMethod · 0.95
newLogLineFunction · 0.85
NewJSONParserFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…