test: TestServiceULimitsNoFile_MergeLastWin

This commit is contained in:
Markus Pesch 2023-07-24 10:26:03 +02:00
parent e8b3d3bb13
commit a57379ef2c
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982

View File

@ -872,6 +872,83 @@ func TestServiceULimitsNoFile_Equal(t *testing.T) {
}
}
func TestServiceULimitsNoFile_MergeLastWin(t *testing.T) {
require := require.New(t)
testCases := []struct {
ServiceULimitsNoFileA *dockerCompose.ServiceULimitsNoFile
ServiceULimitsNoFileB *dockerCompose.ServiceULimitsNoFile
expectedServiceULimitsNoFile *dockerCompose.ServiceULimitsNoFile
}{
{
ServiceULimitsNoFileA: &dockerCompose.ServiceULimitsNoFile{},
ServiceULimitsNoFileB: nil,
expectedServiceULimitsNoFile: &dockerCompose.ServiceULimitsNoFile{},
},
{
ServiceULimitsNoFileA: &dockerCompose.ServiceULimitsNoFile{
Hard: 10,
Soft: 10,
},
ServiceULimitsNoFileB: &dockerCompose.ServiceULimitsNoFile{
Hard: 10,
Soft: 10,
},
expectedServiceULimitsNoFile: &dockerCompose.ServiceULimitsNoFile{
Hard: 10,
Soft: 10,
},
},
{
ServiceULimitsNoFileA: &dockerCompose.ServiceULimitsNoFile{
Hard: 10,
Soft: 10,
},
ServiceULimitsNoFileB: &dockerCompose.ServiceULimitsNoFile{
Hard: 20,
Soft: 10,
},
expectedServiceULimitsNoFile: &dockerCompose.ServiceULimitsNoFile{
Hard: 20,
Soft: 10,
},
},
{
ServiceULimitsNoFileA: &dockerCompose.ServiceULimitsNoFile{
Hard: 10,
Soft: 10,
},
ServiceULimitsNoFileB: &dockerCompose.ServiceULimitsNoFile{
Hard: 10,
Soft: 20,
},
expectedServiceULimitsNoFile: &dockerCompose.ServiceULimitsNoFile{
Hard: 10,
Soft: 20,
},
},
{
ServiceULimitsNoFileA: &dockerCompose.ServiceULimitsNoFile{
Hard: 10,
Soft: 10,
},
ServiceULimitsNoFileB: &dockerCompose.ServiceULimitsNoFile{
Hard: 20,
Soft: 20,
},
expectedServiceULimitsNoFile: &dockerCompose.ServiceULimitsNoFile{
Hard: 20,
Soft: 20,
},
},
}
for i, testCase := range testCases {
testCase.ServiceULimitsNoFileA.MergeLastWin(testCase.ServiceULimitsNoFileB)
require.Equal(testCase.expectedServiceULimitsNoFile, testCase.ServiceULimitsNoFileA, "Failed test case %v", i)
}
}
func TestVolume_Equal(t *testing.T) {
require := require.New(t)