Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zak-pawel committed Oct 24, 2023
1 parent 43afbcd commit 7d747b3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 36 deletions.
9 changes: 3 additions & 6 deletions plugins/inputs/aerospike/aerospike_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,9 @@ func TestAerospikeParseValue(t *testing.T) {
require.Equal(t, uint64(18446744041841121751), val)

val = parseAerospikeValue("", "true")
switch v := val.(type) {
case bool:
require.True(t, v)
default:
require.Fail(t, fmt.Sprintf("bool type expected, got '%T' with '%v' value instead", val, val))
}
v, ok := val.(bool)
require.Truef(t, ok, "bool type expected, got '%T' with '%v' value instead", val, val)
require.True(t, v)

// int values
val = parseAerospikeValue("", "42")
Expand Down
11 changes: 4 additions & 7 deletions plugins/inputs/couchbase/couchbase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package couchbase

import (
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -211,12 +210,10 @@ func TestGatherFailover(t *testing.T) {

require.NotNil(t, metric)
require.Equal(t, 1, metric.Fields["count"])
switch v := metric.Fields["enabled"].(type) {
case bool:
require.True(t, v)
default:
require.Fail(t, fmt.Sprintf("bool type expected, got '%T' with '%v' value instead", metric.Fields["enabled"], metric.Fields["enabled"]))
}
v, ok := metric.Fields["enabled"].(bool)
require.Truef(t, ok, "bool type expected, got '%T' with '%v' value instead", metric.Fields["enabled"], metric.Fields["enabled"])
require.True(t, v)

require.Equal(t, 2, metric.Fields["max_count"])
require.Equal(t, 72, metric.Fields["timeout"])
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/inputs/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package github

import (
"net/http"
"reflect"
"testing"

gh "github.com/google/go-github/v32/github"
Expand Down Expand Up @@ -103,7 +102,7 @@ func TestGetTags(t *testing.T) {
"license": licenseName,
}

require.True(t, reflect.DeepEqual(getTagsReturn, correctTagsReturn))
require.Equal(t, getTagsReturn, correctTagsReturn)
}

func TestGetFields(t *testing.T) {
Expand Down Expand Up @@ -136,5 +135,5 @@ func TestGetFields(t *testing.T) {
correctFieldReturn["subscribers"] = 5
correctFieldReturn["watchers"] = 6

require.True(t, reflect.DeepEqual(getFieldsReturn, correctFieldReturn))
require.Equal(t, getFieldsReturn, correctFieldReturn)
}
18 changes: 6 additions & 12 deletions plugins/inputs/knx_listener/knx_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,14 @@ func TestRegularReceives_MultipleMessages(t *testing.T) {
require.Equal(t, "temperature", acc.Metrics[0].Measurement)
require.Equal(t, "1/1/1", acc.Metrics[0].Tags["groupaddress"])
require.Len(t, acc.Metrics[0].Fields, 1)
switch v := acc.Metrics[0].Fields["value"].(type) {
case bool:
require.True(t, v)
default:
require.Fail(t, fmt.Sprintf("bool type expected, got '%T' with '%v' value instead", acc.Metrics[0].Fields["value"], acc.Metrics[0].Fields["value"]))
}
v, ok := acc.Metrics[0].Fields["value"].(bool)
require.Truef(t, ok, "bool type expected, got '%T' with '%v' value instead", acc.Metrics[0].Fields["value"], acc.Metrics[0].Fields["value"])
require.True(t, v)

require.Equal(t, "temperature", acc.Metrics[1].Measurement)
require.Equal(t, "1/1/1", acc.Metrics[1].Tags["groupaddress"])
require.Len(t, acc.Metrics[1].Fields, 1)
switch v := acc.Metrics[1].Fields["value"].(type) {
case bool:
require.False(t, v)
default:
require.Fail(t, fmt.Sprintf("bool type expected, got '%T' with '%v' value instead", acc.Metrics[1].Fields["value"], acc.Metrics[1].Fields["value"]))
}
v, ok = acc.Metrics[1].Fields["value"].(bool)
require.Truef(t, ok, "bool type expected, got '%T' with '%v' value instead", acc.Metrics[1].Fields["value"], acc.Metrics[1].Fields["value"])
require.False(t, v)
}
9 changes: 3 additions & 6 deletions plugins/inputs/ping/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package ping
import (
"errors"
"fmt"
"reflect"
"sort"
"testing"
"time"
Expand Down Expand Up @@ -177,8 +176,7 @@ func TestArgs(t *testing.T) {
expected := systemCases[i].output
sort.Strings(actual)
sort.Strings(expected)
require.True(t, reflect.DeepEqual(expected, actual),
"Expected: %s Actual: %s", expected, actual)
require.Equal(t, expected, actual)
}
}

Expand Down Expand Up @@ -206,8 +204,7 @@ func TestArgs6(t *testing.T) {
expected := systemCases[i].output
sort.Strings(actual)
sort.Strings(expected)
require.True(t, reflect.DeepEqual(expected, actual),
"Expected: %s Actual: %s", expected, actual)
require.Equal(t, expected, actual)
}
}

Expand All @@ -225,7 +222,7 @@ func TestArguments(t *testing.T) {

for _, system := range []string{"darwin", "linux", "anything else"} {
actual := p.args("www.google.com", system)
require.True(t, reflect.DeepEqual(actual, expected), "Expected: %s Actual: %s", expected, actual)
require.Equal(t, actual, expected)
}
}

Expand Down
3 changes: 1 addition & 2 deletions plugins/inputs/ping/ping_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package ping

import (
"errors"
"reflect"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -143,7 +142,7 @@ func TestArguments(t *testing.T) {
}

actual := p.args("www.google.com")
require.True(t, reflect.DeepEqual(actual, arguments), "Expected : %s Actual: %s", arguments, actual)
require.Equal(t, actual, arguments)
}

var lossyPingOutput = `
Expand Down

0 comments on commit 7d747b3

Please sign in to comment.