github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/nomad/structs/node_test.go (about) 1 package structs 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestDriverInfoEquals(t *testing.T) { 10 require := require.New(t) 11 var driverInfoTest = []struct { 12 input []*DriverInfo 13 expected bool 14 errorMsg string 15 }{ 16 { 17 []*DriverInfo{ 18 { 19 Healthy: true, 20 }, 21 { 22 Healthy: false, 23 }, 24 }, 25 false, 26 "Different healthy values should not be equal.", 27 }, 28 { 29 []*DriverInfo{ 30 { 31 HealthDescription: "not running", 32 }, 33 { 34 HealthDescription: "running", 35 }, 36 }, 37 false, 38 "Different health description values should not be equal.", 39 }, 40 { 41 []*DriverInfo{ 42 { 43 Detected: false, 44 Healthy: true, 45 HealthDescription: "This driver is ok", 46 }, 47 { 48 Detected: true, 49 Healthy: true, 50 HealthDescription: "This driver is ok", 51 }, 52 }, 53 true, 54 "Same health check should be equal", 55 }, 56 } 57 for _, testCase := range driverInfoTest { 58 first := testCase.input[0] 59 second := testCase.input[1] 60 require.Equal(testCase.expected, first.HealthCheckEquals(second), testCase.errorMsg) 61 } 62 }