Skip to content

Commit

Permalink
http_response input: Fix a couple of bugs in the helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Germán Jaber committed Feb 24, 2018
1 parent 81722d8 commit 02dd69c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions plugins/inputs/http_response/http_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func checkFields(t *testing.T, fields map[string]interface{}, acc testutil.Accum

// Receives a dictionary and with expected tags and their values. If a value is nil, it will only check
// that the tag exists, but not its contents
func checkTags(t *testing.T, tag map[string]interface{}, acc testutil.Accumulator) {
for key, tag := range tag {
func checkTags(t *testing.T, tags map[string]interface{}, acc testutil.Accumulator) {
for key, tag := range tags {
switch v := tag.(type) {
case string:
ok := acc.HasTag("http_response", key)
Expand Down Expand Up @@ -119,10 +119,21 @@ func setUpTestMux() http.Handler {
}

func checkOutput(t *testing.T, acc testutil.Accumulator, presentFields map[string]interface{}, presentTags map[string]interface{}, absentFields []string, absentTags []string) {
checkFields(t, presentFields, acc)
checkTags(t, presentTags, acc)
checkAbsentFields(t, absentFields, acc)
checkAbsentTags(t, absentTags, acc)
if presentFields != nil {
checkFields(t, presentFields, acc)
}

if presentTags != nil {
checkTags(t, presentTags, acc)
}

if absentFields != nil {
checkAbsentFields(t, absentFields, acc)
}

if absentTags != nil {
checkAbsentTags(t, absentTags, acc)
}
}

func TestHeaders(t *testing.T) {
Expand Down

0 comments on commit 02dd69c

Please sign in to comment.