Browse Source

module: change assert.Equal arguments to match (expected, actual)

pull/25/head
cn 2 years ago
parent
commit
befef9d063
  1. 20
      cmd/miflorad/formatters_test.go
  2. 2
      common/datatypes_test.go
  3. 4
      common/proto_test.go

20
cmd/miflorad/formatters_test.go

@ -34,9 +34,9 @@ func TestPublishGraphite(t *testing.T) {
case mifloraErrorMetric:
for line := range publish {
parts := strings.Split(line, " ")
assert.Equal(t, len(parts), 3)
assert.Equal(t, parts[0], "foo.base.miflora.peri.failed")
assert.Equal(t, parts[1], "1")
assert.Equal(t, 3, len(parts))
assert.Equal(t, "foo.base.miflora.peri.failed", parts[0])
assert.Equal(t, "1", parts[1])
timestamp, err := strconv.ParseInt(parts[2], 10, 64)
assert.NoError(t, err)
assert.True(t, timestamp >= 0)
@ -44,8 +44,8 @@ func TestPublishGraphite(t *testing.T) {
case mifloraDataMetric:
for line := range publish {
parts := strings.Split(line, " ")
assert.Equal(t, len(parts), 3)
assert.Equal(t, strings.Index(parts[0], "foo.base.miflora.peri"), 0)
assert.Equal(t, 3, len(parts))
assert.Equal(t, 0, strings.Index(parts[0], "foo.base.miflora.peri"))
assert.True(t, len(parts[1]) > 0)
timestamp, err := strconv.ParseInt(parts[2], 10, 64)
assert.NoError(t, err)
@ -78,17 +78,17 @@ func TestPublishInflux(t *testing.T) {
case mifloraErrorMetric:
line := <-publish
parts := strings.Split(line, " ")
assert.Equal(t, len(parts), 3)
assert.Equal(t, parts[0], "miflora,id=peri")
assert.Equal(t, parts[1], "failed=1")
assert.Equal(t, 3, len(parts))
assert.Equal(t, "miflora,id=peri", parts[0])
assert.Equal(t, "failed=1", parts[1])
timestamp, err := strconv.ParseInt(parts[2], 10, 64)
assert.NoError(t, err)
assert.True(t, timestamp >= 0)
case mifloraDataMetric:
line := <-publish
parts := strings.Split(line, " ")
assert.Equal(t, len(parts), 3)
assert.Equal(t, parts[0], "miflora,id=peri")
assert.Equal(t, 3, len(parts))
assert.Equal(t, "miflora,id=peri", parts[0])
assert.True(t, len(parts[1]) > 0)
timestamp, err := strconv.ParseInt(parts[2], 10, 64)
assert.NoError(t, err)

2
common/datatypes_test.go

@ -19,6 +19,6 @@ func TestNumericFirmwareVersion(t *testing.T) {
}
for _, table := range tables {
assert.Equal(t, table.metaData.NumericFirmwareVersion(), table.firmware)
assert.Equal(t, table.firmware, table.metaData.NumericFirmwareVersion())
}
}

4
common/proto_test.go

@ -19,7 +19,7 @@ func TestParseVersionBattery(t *testing.T) {
}
for _, table := range tables {
assert.Equal(t, ParseVersionBattery(table.bytes), table.metaData)
assert.Equal(t, table.metaData, ParseVersionBattery(table.bytes))
}
}
@ -40,6 +40,6 @@ func TestParseSensorData(t *testing.T) {
}
for _, table := range tables {
assert.Equal(t, ParseSensorData(table.bytes), table.sensorData)
assert.Equal(t, table.sensorData, ParseSensorData(table.bytes))
}
}
Loading…
Cancel
Save