test(dockerCompose): add Volume.MergeFirstWin()

This commit is contained in:
Markus Pesch 2023-08-27 18:57:27 +02:00
parent a656dc2db1
commit 1207bcfcab
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982

View File

@ -2079,6 +2079,65 @@ func TestVolume_Equal(t *testing.T) {
}
}
func TestVolume_MergeFirstWin(t *testing.T) {
require := require.New(t)
testCases := []struct {
volumeA *dockerCompose.Volume
volumeB *dockerCompose.Volume
expectedVolume *dockerCompose.Volume
}{
{
volumeA: nil,
volumeB: nil,
expectedVolume: nil,
},
{
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: true,
},
},
{
volumeA: &dockerCompose.Volume{
External: false,
},
volumeB: &dockerCompose.Volume{
External: true,
},
expectedVolume: &dockerCompose.Volume{
External: true,
},
},
}
for i, testCase := range testCases {
testCase.volumeA.MergeFirstWin(testCase.volumeB)
require.True(testCase.expectedVolume.Equal(testCase.volumeA), "Failed test case %v", i)
}
}
func TestVolume_MergeLastWin(t *testing.T) {
require := require.New(t)