diff --git a/pkg/domain/dockerCompose/config.go b/pkg/domain/dockerCompose/config.go index 63e8cd0..216230f 100644 --- a/pkg/domain/dockerCompose/config.go +++ b/pkg/domain/dockerCompose/config.go @@ -751,7 +751,7 @@ func (l *ServiceULimits) MergeLastWin(serviceULimits *ServiceULimits) { // fallthrough default: - l.mergeLastWinNProc(l.NProc) + l.mergeLastWinNProc(serviceULimits.NProc) l.mergeLastWinNoFile(serviceULimits.NoFile) } } diff --git a/pkg/domain/dockerCompose/config_test.go b/pkg/domain/dockerCompose/config_test.go index 879b2f9..927fc70 100644 --- a/pkg/domain/dockerCompose/config_test.go +++ b/pkg/domain/dockerCompose/config_test.go @@ -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)