|
@@ -179,10 +179,9 @@ func TestConvertEndpointSpec(t *testing.T) {
|
|
|
|
|
|
func TestConvertServiceNetworksOnlyDefault(t *testing.T) {
|
|
func TestConvertServiceNetworksOnlyDefault(t *testing.T) {
|
|
networkConfigs := networkMap{}
|
|
networkConfigs := networkMap{}
|
|
- networks := map[string]*composetypes.ServiceNetworkConfig{}
|
|
|
|
|
|
|
|
configs, err := convertServiceNetworks(
|
|
configs, err := convertServiceNetworks(
|
|
- networks, networkConfigs, NewNamespace("foo"), "service")
|
|
|
|
|
|
+ nil, networkConfigs, NewNamespace("foo"), "service")
|
|
|
|
|
|
expected := []swarm.NetworkAttachmentConfig{
|
|
expected := []swarm.NetworkAttachmentConfig{
|
|
{
|
|
{
|
|
@@ -235,6 +234,31 @@ func TestConvertServiceNetworks(t *testing.T) {
|
|
assert.DeepEqual(t, []swarm.NetworkAttachmentConfig(sortedConfigs), expected)
|
|
assert.DeepEqual(t, []swarm.NetworkAttachmentConfig(sortedConfigs), expected)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func TestConvertServiceNetworksCustomDefault(t *testing.T) {
|
|
|
|
+ networkConfigs := networkMap{
|
|
|
|
+ "default": composetypes.NetworkConfig{
|
|
|
|
+ External: composetypes.External{
|
|
|
|
+ External: true,
|
|
|
|
+ Name: "custom",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ networks := map[string]*composetypes.ServiceNetworkConfig{}
|
|
|
|
+
|
|
|
|
+ configs, err := convertServiceNetworks(
|
|
|
|
+ networks, networkConfigs, NewNamespace("foo"), "service")
|
|
|
|
+
|
|
|
|
+ expected := []swarm.NetworkAttachmentConfig{
|
|
|
|
+ {
|
|
|
|
+ Target: "custom",
|
|
|
|
+ Aliases: []string{"service"},
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ assert.NilError(t, err)
|
|
|
|
+ assert.DeepEqual(t, []swarm.NetworkAttachmentConfig(configs), expected)
|
|
|
|
+}
|
|
|
|
+
|
|
type byTargetSort []swarm.NetworkAttachmentConfig
|
|
type byTargetSort []swarm.NetworkAttachmentConfig
|
|
|
|
|
|
func (s byTargetSort) Len() int {
|
|
func (s byTargetSort) Len() int {
|