2018-02-27 19:57:10 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDriverInfoEquals(t *testing.T) {
|
|
|
|
require := require.New(t)
|
|
|
|
var driverInfoTest = []struct {
|
|
|
|
input []*DriverInfo
|
|
|
|
expected bool
|
|
|
|
errorMsg string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
[]*DriverInfo{
|
2018-02-28 17:40:54 +00:00
|
|
|
{
|
2018-02-27 19:57:10 +00:00
|
|
|
Healthy: true,
|
|
|
|
},
|
2018-02-28 17:40:54 +00:00
|
|
|
{
|
2018-02-27 19:57:10 +00:00
|
|
|
Healthy: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
"Different healthy values should not be equal.",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
[]*DriverInfo{
|
2018-02-28 17:40:54 +00:00
|
|
|
{
|
2018-02-27 19:57:10 +00:00
|
|
|
HealthDescription: "not running",
|
|
|
|
},
|
2018-02-28 17:40:54 +00:00
|
|
|
{
|
2018-02-27 19:57:10 +00:00
|
|
|
HealthDescription: "running",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
"Different health description values should not be equal.",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
[]*DriverInfo{
|
2018-02-28 17:40:54 +00:00
|
|
|
{
|
2018-03-20 17:25:07 +00:00
|
|
|
Detected: false,
|
2018-02-27 19:57:10 +00:00
|
|
|
Healthy: true,
|
2018-03-20 17:25:07 +00:00
|
|
|
HealthDescription: "This driver is ok",
|
2018-02-27 19:57:10 +00:00
|
|
|
},
|
2018-02-28 17:40:54 +00:00
|
|
|
{
|
2018-03-20 17:25:07 +00:00
|
|
|
Detected: true,
|
2018-02-27 19:57:10 +00:00
|
|
|
Healthy: true,
|
2018-03-20 17:25:07 +00:00
|
|
|
HealthDescription: "This driver is ok",
|
2018-02-27 19:57:10 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
true,
|
2018-03-20 17:25:07 +00:00
|
|
|
"Same health check should be equal",
|
2018-02-27 19:57:10 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, testCase := range driverInfoTest {
|
|
|
|
first := testCase.input[0]
|
|
|
|
second := testCase.input[1]
|
|
|
|
require.Equal(testCase.expected, first.HealthCheckEquals(second), testCase.errorMsg)
|
|
|
|
}
|
|
|
|
}
|