test: TestServiceULimits_MergeLastWin
This commit is contained in:
parent
a57379ef2c
commit
066b52f94e
@ -751,7 +751,7 @@ func (l *ServiceULimits) MergeLastWin(serviceULimits *ServiceULimits) {
|
||||
// fallthrough
|
||||
|
||||
default:
|
||||
l.mergeLastWinNProc(l.NProc)
|
||||
l.mergeLastWinNProc(serviceULimits.NProc)
|
||||
l.mergeLastWinNoFile(serviceULimits.NoFile)
|
||||
}
|
||||
}
|
||||
|
@ -822,6 +822,49 @@ func TestServiceULimits_Equal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceULimits_MergeLastWin(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
testCases := []struct {
|
||||
ServiceULimitsA *dockerCompose.ServiceULimits
|
||||
ServiceULimitsB *dockerCompose.ServiceULimits
|
||||
expectedServiceULimits *dockerCompose.ServiceULimits
|
||||
}{
|
||||
{
|
||||
ServiceULimitsA: &dockerCompose.ServiceULimits{},
|
||||
ServiceULimitsB: nil,
|
||||
expectedServiceULimits: &dockerCompose.ServiceULimits{},
|
||||
},
|
||||
{
|
||||
ServiceULimitsA: &dockerCompose.ServiceULimits{
|
||||
NProc: 10,
|
||||
},
|
||||
ServiceULimitsB: &dockerCompose.ServiceULimits{
|
||||
NProc: 10,
|
||||
},
|
||||
expectedServiceULimits: &dockerCompose.ServiceULimits{
|
||||
NProc: 10,
|
||||
},
|
||||
},
|
||||
{
|
||||
ServiceULimitsA: &dockerCompose.ServiceULimits{
|
||||
NProc: 10,
|
||||
},
|
||||
ServiceULimitsB: &dockerCompose.ServiceULimits{
|
||||
NProc: 20,
|
||||
},
|
||||
expectedServiceULimits: &dockerCompose.ServiceULimits{
|
||||
NProc: 20,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
testCase.ServiceULimitsA.MergeLastWin(testCase.ServiceULimitsB)
|
||||
require.Equal(testCase.expectedServiceULimits, testCase.ServiceULimitsA, "Failed test case %v", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceULimitsNoFile_Equal(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user