From e8b3d3bb13659b5d90f3ade1fc0a22bf7fd2f298 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Mon, 24 Jul 2023 10:22:54 +0200 Subject: [PATCH] test: TestVolume_MergeLastWin --- pkg/domain/dockerCompose/config_test.go | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/pkg/domain/dockerCompose/config_test.go b/pkg/domain/dockerCompose/config_test.go index 0758d01..1904795 100644 --- a/pkg/domain/dockerCompose/config_test.go +++ b/pkg/domain/dockerCompose/config_test.go @@ -919,3 +919,46 @@ func TestVolume_Equal(t *testing.T) { require.Equal(testCase.expectedResult, testCase.equalableA.Equal(testCase.equalableB), "Failed test case %v", i) } } + +func TestVolume_MergeLastWin(t *testing.T) { + require := require.New(t) + + testCases := []struct { + volumeA *dockerCompose.Volume + volumeB *dockerCompose.Volume + expectedVolume *dockerCompose.Volume + }{ + { + volumeA: &dockerCompose.Volume{}, + volumeB: nil, + expectedVolume: &dockerCompose.Volume{}, + }, + { + volumeA: &dockerCompose.Volume{ + External: true, + }, + volumeB: &dockerCompose.Volume{ + External: true, + }, + expectedVolume: &dockerCompose.Volume{ + External: true, + }, + }, + { + volumeA: &dockerCompose.Volume{ + External: true, + }, + volumeB: &dockerCompose.Volume{ + External: false, + }, + expectedVolume: &dockerCompose.Volume{ + External: false, + }, + }, + } + + for i, testCase := range testCases { + testCase.volumeA.MergeLastWin(testCase.volumeB) + require.Equal(testCase.expectedVolume, testCase.volumeA, "Failed test case %v", i) + } +}