test: volume

This commit is contained in:
Markus Pesch 2023-07-21 16:47:08 +02:00
parent 70f33eb0df
commit db9f0c5e52
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982

View File

@ -316,3 +316,51 @@ func TestServiceULimitsNoFile_Equal(t *testing.T) {
require.Equal(testCase.expectedResult, testCase.equalableA.Equal(testCase.equalableB), "Failed test case %v", i)
}
}
func TestVolume_Equal(t *testing.T) {
require := require.New(t)
testCases := []struct {
equalableA dockerCompose.Equalable
equalableB dockerCompose.Equalable
expectedResult bool
}{
{
equalableA: &dockerCompose.Volume{},
equalableB: &dockerCompose.NetworkIPAM{},
expectedResult: false,
},
{
equalableA: &dockerCompose.Volume{},
equalableB: nil,
expectedResult: false,
},
{
equalableA: dockerCompose.NewVolume(),
equalableB: dockerCompose.NewVolume(),
expectedResult: true,
},
{
equalableA: &dockerCompose.Volume{
External: true,
},
equalableB: &dockerCompose.Volume{
External: false,
},
expectedResult: false,
},
{
equalableA: &dockerCompose.Volume{
External: true,
},
equalableB: &dockerCompose.Volume{
External: true,
},
expectedResult: true,
},
}
for i, testCase := range testCases {
require.Equal(testCase.expectedResult, testCase.equalableA.Equal(testCase.equalableB), "Failed test case %v", i)
}
}