test: TestVolume_MergeLastWin

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

View File

@ -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)
}
}