github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/nomad/structs/node_test.go (about)

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