test: network equal

This commit is contained in:
Markus Pesch 2023-07-21 16:15:35 +02:00
parent ff604ccc39
commit f6b1891d98
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982

View File

@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestServiceDeployResourcesLimits_EqualAndMergeLastWin(t *testing.T) {
func TestServiceDeployResourcesLimits_Equal(t *testing.T) {
require := require.New(t)
testCases := []struct {
@ -134,3 +134,68 @@ func TestServiceDeployResourcesLimits_MergeLastWin(t *testing.T) {
require.True(testCase.expectedResult.Equal(testCase.serviceDeploymentResourcesLimitsA), "Failed test case %v", i)
}
}
func TestServiceNetwork_Equal(t *testing.T) {
require := require.New(t)
testCases := []struct {
equalableA dockerCompose.Equalable
equalableB dockerCompose.Equalable
expectedResult bool
}{
{
equalableA: &dockerCompose.ServiceNetwork{
Aliases: []string{},
},
equalableB: &dockerCompose.NetworkIPAM{},
expectedResult: false,
},
{
equalableA: &dockerCompose.ServiceNetwork{
Aliases: []string{},
},
equalableB: nil,
expectedResult: false,
},
{
equalableA: &dockerCompose.ServiceNetwork{
Aliases: []string{},
},
equalableB: &dockerCompose.ServiceNetwork{
Aliases: []string{},
},
expectedResult: true,
},
{
equalableA: &dockerCompose.ServiceNetwork{
Aliases: []string{"HelloWorld"},
},
equalableB: &dockerCompose.ServiceNetwork{
Aliases: []string{"HelloWorld"},
},
expectedResult: true,
},
{
equalableA: &dockerCompose.ServiceNetwork{
Aliases: []string{"HelloWorld"},
},
equalableB: &dockerCompose.ServiceNetwork{
Aliases: []string{"FooBar"},
},
expectedResult: false,
},
{
equalableA: &dockerCompose.ServiceNetwork{
Aliases: []string{"Hello", "World"},
},
equalableB: &dockerCompose.ServiceNetwork{
Aliases: []string{"FooBar"},
},
expectedResult: false,
},
}
for i, testCase := range testCases {
require.Equal(testCase.expectedResult, testCase.equalableA.Equal(testCase.equalableB), "Failed test case %v", i)
}
}