test: TestServiceNetwork_MergeLastWin
This commit is contained in:
parent
066b52f94e
commit
a8984ead0e
@ -755,6 +755,49 @@ func TestServiceNetwork_Equal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceNetwork_MergeLastWin(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
testCases := []struct {
|
||||
ServiceNetworkA *dockerCompose.ServiceNetwork
|
||||
ServiceNetworkB *dockerCompose.ServiceNetwork
|
||||
expectedServiceNetwork *dockerCompose.ServiceNetwork
|
||||
}{
|
||||
{
|
||||
ServiceNetworkA: &dockerCompose.ServiceNetwork{},
|
||||
ServiceNetworkB: nil,
|
||||
expectedServiceNetwork: &dockerCompose.ServiceNetwork{},
|
||||
},
|
||||
{
|
||||
ServiceNetworkA: &dockerCompose.ServiceNetwork{
|
||||
Aliases: []string{"my-app.example.com"},
|
||||
},
|
||||
ServiceNetworkB: &dockerCompose.ServiceNetwork{
|
||||
Aliases: []string{"my-app.example.com"},
|
||||
},
|
||||
expectedServiceNetwork: &dockerCompose.ServiceNetwork{
|
||||
Aliases: []string{"my-app.example.com"},
|
||||
},
|
||||
},
|
||||
{
|
||||
ServiceNetworkA: &dockerCompose.ServiceNetwork{
|
||||
Aliases: []string{"my-app.example.com"},
|
||||
},
|
||||
ServiceNetworkB: &dockerCompose.ServiceNetwork{
|
||||
Aliases: []string{"my-app.example.local"},
|
||||
},
|
||||
expectedServiceNetwork: &dockerCompose.ServiceNetwork{
|
||||
Aliases: []string{"my-app.example.com", "my-app.example.local"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
testCase.ServiceNetworkA.MergeLastWin(testCase.ServiceNetworkB)
|
||||
require.True(testCase.expectedServiceNetwork.Equal(testCase.ServiceNetworkA), "Failed test case %v", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceULimits_Equal(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
@ -861,7 +904,7 @@ func TestServiceULimits_MergeLastWin(t *testing.T) {
|
||||
|
||||
for i, testCase := range testCases {
|
||||
testCase.ServiceULimitsA.MergeLastWin(testCase.ServiceULimitsB)
|
||||
require.Equal(testCase.expectedServiceULimits, testCase.ServiceULimitsA, "Failed test case %v", i)
|
||||
require.True(testCase.expectedServiceULimits.Equal(testCase.ServiceULimitsA), "Failed test case %v", i)
|
||||
}
|
||||
}
|
||||
|
||||
@ -988,7 +1031,7 @@ func TestServiceULimitsNoFile_MergeLastWin(t *testing.T) {
|
||||
|
||||
for i, testCase := range testCases {
|
||||
testCase.ServiceULimitsNoFileA.MergeLastWin(testCase.ServiceULimitsNoFileB)
|
||||
require.Equal(testCase.expectedServiceULimitsNoFile, testCase.ServiceULimitsNoFileA, "Failed test case %v", i)
|
||||
require.True(testCase.expectedServiceULimitsNoFile.Equal(testCase.ServiceULimitsNoFileA), "Failed test case %v", i)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1079,6 +1122,6 @@ func TestVolume_MergeLastWin(t *testing.T) {
|
||||
|
||||
for i, testCase := range testCases {
|
||||
testCase.volumeA.MergeLastWin(testCase.volumeB)
|
||||
require.Equal(testCase.expectedVolume, testCase.volumeA, "Failed test case %v", i)
|
||||
require.True(testCase.expectedVolume.Equal(testCase.volumeA), "Failed test case %v", i)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user