From db9f0c5e522fe9ee9203c2697a37ccf2eea8f799 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 21 Jul 2023 16:47:08 +0200 Subject: [PATCH] test: volume --- pki/domain/dockerCompose/config_test.go | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/pki/domain/dockerCompose/config_test.go b/pki/domain/dockerCompose/config_test.go index 3a01a2e..4782118 100644 --- a/pki/domain/dockerCompose/config_test.go +++ b/pki/domain/dockerCompose/config_test.go @@ -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) + } +}