edit unittests for JSON parser

This commit is contained in:
Max U 2018-06-27 15:53:52 -07:00
parent 420dafd591
commit c50bfc2c71
9 changed files with 14 additions and 14 deletions

View File

@ -93,7 +93,7 @@ func (r runnerMock) Run(e *Exec, command string, acc telegraf.Accumulator) ([]by
}
func TestExec(t *testing.T) {
parser, _ := parsers.NewJSONParser("exec", []string{}, nil)
parser, _ := parsers.NewJSONParser("exec", []string{}, nil, nil)
e := &Exec{
runner: newRunnerMock([]byte(validJson), nil),
Commands: []string{"testcommand arg1"},
@ -119,7 +119,7 @@ func TestExec(t *testing.T) {
}
func TestExecMalformed(t *testing.T) {
parser, _ := parsers.NewJSONParser("exec", []string{}, nil)
parser, _ := parsers.NewJSONParser("exec", []string{}, nil, nil)
e := &Exec{
runner: newRunnerMock([]byte(malformedJson), nil),
Commands: []string{"badcommand arg1"},
@ -132,7 +132,7 @@ func TestExecMalformed(t *testing.T) {
}
func TestCommandError(t *testing.T) {
parser, _ := parsers.NewJSONParser("exec", []string{}, nil)
parser, _ := parsers.NewJSONParser("exec", []string{}, nil, nil)
e := &Exec{
runner: newRunnerMock(nil, fmt.Errorf("exit status code 1")),
Commands: []string{"badcommand"},

View File

@ -26,7 +26,7 @@ func TestHTTPwithJSONFormat(t *testing.T) {
URLs: []string{url},
}
metricName := "metricName"
p, _ := parsers.NewJSONParser(metricName, nil, nil)
p, _ := parsers.NewJSONParser(metricName, nil, nil, nil)
plugin.SetParser(p)
var acc testutil.Accumulator
@ -64,7 +64,7 @@ func TestHTTPHeaders(t *testing.T) {
Headers: map[string]string{header: headerValue},
}
metricName := "metricName"
p, _ := parsers.NewJSONParser(metricName, nil, nil)
p, _ := parsers.NewJSONParser(metricName, nil, nil, nil)
plugin.SetParser(p)
var acc testutil.Accumulator
@ -83,7 +83,7 @@ func TestInvalidStatusCode(t *testing.T) {
}
metricName := "metricName"
p, _ := parsers.NewJSONParser(metricName, nil, nil)
p, _ := parsers.NewJSONParser(metricName, nil, nil, nil)
plugin.SetParser(p)
var acc testutil.Accumulator
@ -106,7 +106,7 @@ func TestMethod(t *testing.T) {
}
metricName := "metricName"
p, _ := parsers.NewJSONParser(metricName, nil, nil)
p, _ := parsers.NewJSONParser(metricName, nil, nil, nil)
plugin.SetParser(p)
var acc testutil.Accumulator

View File

@ -181,7 +181,7 @@ func (h *HttpJson) gatherServer(
"server": serverURL,
}
parser, err := parsers.NewJSONParser(msrmnt_name, h.TagKeys, tags)
parser, err := parsers.NewJSONParser(msrmnt_name, h.TagKeys, nil, tags)
if err != nil {
return err
}

View File

@ -125,7 +125,7 @@ func TestRunParserAndGatherJSON(t *testing.T) {
k.acc = &acc
defer close(k.done)
k.parser, _ = parsers.NewJSONParser("kafka_json_test", []string{}, nil)
k.parser, _ = parsers.NewJSONParser("kafka_json_test", []string{}, nil, nil)
go k.receiver()
in <- saramaMsg(testMsgJSON)
acc.Wait(1)

View File

@ -125,7 +125,7 @@ func TestRunParserAndGatherJSON(t *testing.T) {
k.acc = &acc
defer close(k.done)
k.parser, _ = parsers.NewJSONParser("kafka_json_test", []string{}, nil)
k.parser, _ = parsers.NewJSONParser("kafka_json_test", []string{}, nil, nil)
go k.receiver()
in <- saramaMsg(testMsgJSON)
acc.Wait(1)

View File

@ -172,7 +172,7 @@ func TestRunParserAndGatherJSON(t *testing.T) {
n.acc = &acc
defer close(n.done)
n.parser, _ = parsers.NewJSONParser("nats_json_test", []string{}, nil)
n.parser, _ = parsers.NewJSONParser("nats_json_test", []string{}, nil, nil)
go n.receiver()
in <- mqttMsg(testMsgJSON)

View File

@ -108,7 +108,7 @@ func TestRunParserAndGatherJSON(t *testing.T) {
n.acc = &acc
defer close(n.done)
n.parser, _ = parsers.NewJSONParser("nats_json_test", []string{}, nil)
n.parser, _ = parsers.NewJSONParser("nats_json_test", []string{}, nil, nil)
n.wg.Add(1)
go n.receiver()
in <- natsMsg(testMsgJSON)

View File

@ -300,7 +300,7 @@ func TestRunParserJSONMsg(t *testing.T) {
listener.acc = &acc
defer close(listener.done)
listener.parser, _ = parsers.NewJSONParser("udp_json_test", []string{}, nil)
listener.parser, _ = parsers.NewJSONParser("udp_json_test", []string{}, nil, nil)
listener.wg.Add(1)
go listener.tcpParser()

View File

@ -193,7 +193,7 @@ func TestRunParserJSONMsg(t *testing.T) {
listener.acc = &acc
defer close(listener.done)
listener.parser, _ = parsers.NewJSONParser("udp_json_test", []string{}, nil)
listener.parser, _ = parsers.NewJSONParser("udp_json_test", []string{}, nil, nil)
listener.wg.Add(1)
go listener.udpParser()