Skip to content

Commit

Permalink
Better variable naming in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan committed Nov 1, 2023
1 parent bed5827 commit bb365d3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions host/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,8 @@ func TestTemperatureStat_StringNotSet(t *testing.T) {
SensorKey: "CPU",
Temperature: 1.1,
}
s := `{"sensorKey":"CPU","temperature":1.1,"sensorHigh":0,"sensorCritical":0}`
if s != fmt.Sprintf("%v", v) {
t.Errorf("TemperatureStat string is invalid, %v", fmt.Sprintf("%v", v))
}
expected := `{"sensorKey":"CPU","temperature":1.1,"sensorHigh":0,"sensorCritical":0}`
require.Equalf(t, expected, v.String(), "TemperatureStat string is invalid, %s", v)
}

func TestTemperatureStat_StringOptional(t *testing.T) {
Expand All @@ -176,9 +174,9 @@ func TestTemperatureStat_StringOptional(t *testing.T) {
"alarm": 80.3,
},
}
var expected TemperatureStat
require.NoError(t, json.Unmarshal([]byte(v.String()), &expected))
require.EqualValues(t, expected, v)
var actual TemperatureStat
require.NoError(t, json.Unmarshal([]byte(v.String()), &actual))
require.EqualValues(t, v, actual)
}

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

0 comments on commit bb365d3

Please # to comment.