test: TestNetwork_Equal

This commit is contained in:
Markus Pesch 2023-07-24 09:04:23 +02:00
parent db9f0c5e52
commit 7a1d81ece2
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982

View File

@ -7,6 +7,74 @@ import (
"github.com/stretchr/testify/require"
)
func TestNetwork_Equal(t *testing.T) {
require := require.New(t)
testCases := []struct {
equalableA dockerCompose.Equalable
equalableB dockerCompose.Equalable
expectedResult bool
}{
{
equalableA: &dockerCompose.Network{
External: true,
},
equalableB: &dockerCompose.NetworkIPAM{},
expectedResult: false,
},
{
equalableA: &dockerCompose.Network{
External: true,
},
equalableB: nil,
expectedResult: false,
},
{
equalableA: &dockerCompose.Network{
External: false,
Driver: "bridge",
IPAM: nil,
},
equalableB: &dockerCompose.Network{
External: false,
Driver: "bridge",
IPAM: nil,
},
expectedResult: true,
},
{
equalableA: &dockerCompose.Network{
External: false,
Driver: "host",
IPAM: nil,
},
equalableB: &dockerCompose.Network{
External: false,
Driver: "bride",
IPAM: nil,
},
expectedResult: false,
},
{
equalableA: &dockerCompose.Network{
External: true,
Driver: "bridge",
IPAM: nil,
},
equalableB: &dockerCompose.Network{
External: false,
Driver: "bridge",
IPAM: nil,
},
expectedResult: false,
},
}
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)