test: TestNetwork_Equal
This commit is contained in:
parent
db9f0c5e52
commit
7a1d81ece2
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user