1
0
mirror of https://github.com/cmur2/miflorad.git synced 2024-12-22 12:54:25 +01:00

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

This commit is contained in:
cn 2019-03-03 22:59:32 +01:00
parent 388aff5252
commit befef9d063
3 changed files with 13 additions and 13 deletions

View File

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

View File

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

View File

@ -19,7 +19,7 @@ func TestParseVersionBattery(t *testing.T) {
} }
for _, table := range tables { 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 { for _, table := range tables {
assert.Equal(t, ParseSensorData(table.bytes), table.sensorData) assert.Equal(t, table.sensorData, ParseSensorData(table.bytes))
} }
} }