From 0d91cdcc6f6ef0314a6d586cae8ae5a0e6445441 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Mon, 24 Jul 2023 09:10:06 +0200 Subject: [PATCH] test: TestNetworkIPAMConfig_Equal --- pki/domain/dockerCompose/config_test.go | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/pki/domain/dockerCompose/config_test.go b/pki/domain/dockerCompose/config_test.go index c7ae2a8..6d57e0d 100644 --- a/pki/domain/dockerCompose/config_test.go +++ b/pki/domain/dockerCompose/config_test.go @@ -116,6 +116,47 @@ func TestNetworkIPAM_Equal(t *testing.T) { } } +func TestNetworkIPAM_Config(t *testing.T) { + require := require.New(t) + + testCases := []struct { + equalableA dockerCompose.Equalable + equalableB dockerCompose.Equalable + expectedResult bool + }{ + { + equalableA: &dockerCompose.NetworkIPAMConfig{}, + equalableB: &dockerCompose.Service{}, + expectedResult: false, + }, + { + equalableA: &dockerCompose.NetworkIPAMConfig{}, + equalableB: nil, + expectedResult: false, + }, + { + equalableA: &dockerCompose.NetworkIPAMConfig{ + Subnet: "10.12.13.14/15", + }, + equalableB: &dockerCompose.NetworkIPAMConfig{}, + expectedResult: false, + }, + { + equalableA: &dockerCompose.NetworkIPAMConfig{ + Subnet: "10.12.13.14/15", + }, + equalableB: &dockerCompose.NetworkIPAMConfig{ + Subnet: "10.12.13.14/15", + }, + 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)