From d3cbfe400a5122d335be1c4417ec86b4edd47cb3 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Mon, 24 Jul 2023 09:08:03 +0200 Subject: [PATCH] test: TestNetworkIPAM_Equal --- main.go | 7 +++++ pki/domain/dockerCompose/config_test.go | 41 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..081abb2 --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "log" + +func main() { + log.Println("Hello World") +} diff --git a/pki/domain/dockerCompose/config_test.go b/pki/domain/dockerCompose/config_test.go index 2374a29..c7ae2a8 100644 --- a/pki/domain/dockerCompose/config_test.go +++ b/pki/domain/dockerCompose/config_test.go @@ -75,6 +75,47 @@ func TestNetwork_Equal(t *testing.T) { } } +func TestNetworkIPAM_Equal(t *testing.T) { + require := require.New(t) + + testCases := []struct { + equalableA dockerCompose.Equalable + equalableB dockerCompose.Equalable + expectedResult bool + }{ + { + equalableA: &dockerCompose.NetworkIPAM{}, + equalableB: &dockerCompose.Service{}, + expectedResult: false, + }, + { + equalableA: &dockerCompose.NetworkIPAM{}, + equalableB: nil, + expectedResult: false, + }, + { + equalableA: &dockerCompose.NetworkIPAM{ + Configs: make([]*dockerCompose.NetworkIPAMConfig, 0), + }, + equalableB: &dockerCompose.NetworkIPAM{}, + expectedResult: false, + }, + { + equalableA: &dockerCompose.NetworkIPAM{ + Configs: make([]*dockerCompose.NetworkIPAMConfig, 0), + }, + equalableB: &dockerCompose.NetworkIPAM{ + Configs: make([]*dockerCompose.NetworkIPAMConfig, 0), + }, + expectedResult: true, + }, + } + + for i, testCase := range testCases { + require.Equal(testCase.expectedResult, testCase.equalableA.Equal(testCase.equalableB), "Failed test case %v", i) + } +} + func TestServiceDeployResourcesLimits_Equal(t *testing.T) { require := require.New(t)