test: TestServiceDeployResourceLimits_Equal
This commit is contained in:
parent
c77f0ea1a3
commit
c5898b1ce9
@ -540,7 +540,7 @@ func (sdr *ServiceDeployResources) Equal(equalable Equalable) bool {
|
||||
return false
|
||||
default:
|
||||
return sdr.Limits.Equal(serviceDeployResources.Limits) &&
|
||||
sdr.Reservations.Equal(serviceDeployResources)
|
||||
sdr.Reservations.Equal(serviceDeployResources.Reservations)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,6 +464,104 @@ func TestService_Equal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecretDeploy_Equal(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
testCases := []struct {
|
||||
equalableA dockerCompose.Equalable
|
||||
equalableB dockerCompose.Equalable
|
||||
expectedResult bool
|
||||
}{
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeploy{},
|
||||
equalableB: &dockerCompose.Service{},
|
||||
expectedResult: false,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeploy{},
|
||||
equalableB: nil,
|
||||
expectedResult: false,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeploy{
|
||||
Resources: dockerCompose.NewServiceDeployResources(),
|
||||
},
|
||||
equalableB: &dockerCompose.ServiceDeploy{},
|
||||
expectedResult: false,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeploy{
|
||||
Resources: dockerCompose.NewServiceDeployResources(),
|
||||
},
|
||||
equalableB: &dockerCompose.ServiceDeploy{
|
||||
Resources: dockerCompose.NewServiceDeployResources(),
|
||||
},
|
||||
expectedResult: false,
|
||||
},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
require.Equal(testCase.expectedResult, testCase.equalableA.Equal(testCase.equalableB), "Failed test case %v", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecretDeployResources_Equal(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
testCases := []struct {
|
||||
equalableA dockerCompose.Equalable
|
||||
equalableB dockerCompose.Equalable
|
||||
expectedResult bool
|
||||
}{
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeployResources{},
|
||||
equalableB: &dockerCompose.Service{},
|
||||
expectedResult: false,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeployResources{},
|
||||
equalableB: nil,
|
||||
expectedResult: false,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeployResources{
|
||||
Limits: dockerCompose.NewServiceDeployResourcesLimits(),
|
||||
},
|
||||
equalableB: &dockerCompose.ServiceDeployResources{},
|
||||
expectedResult: false,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeployResources{
|
||||
Limits: dockerCompose.NewServiceDeployResourcesLimits(),
|
||||
},
|
||||
equalableB: &dockerCompose.ServiceDeployResources{
|
||||
Limits: dockerCompose.NewServiceDeployResourcesLimits(),
|
||||
},
|
||||
expectedResult: true,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeployResources{
|
||||
Reservations: dockerCompose.NewServiceDeployResourcesLimits(),
|
||||
},
|
||||
equalableB: &dockerCompose.ServiceDeployResources{},
|
||||
expectedResult: false,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.ServiceDeployResources{
|
||||
Reservations: dockerCompose.NewServiceDeployResourcesLimits(),
|
||||
},
|
||||
equalableB: &dockerCompose.ServiceDeployResources{
|
||||
Reservations: dockerCompose.NewServiceDeployResourcesLimits(),
|
||||
},
|
||||
expectedResult: true,
|
||||
},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
require.Equal(testCase.expectedResult, testCase.equalableA.Equal(testCase.equalableB), "Failed test case %v", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceDeployResourcesLimits_Equal(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user