-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change apipa network gw address from .1 to .2 (#2933)
* change gw address to .2 * refactor and add UTs * fix lint * fix loopback adapter default gw address * remote address should always be .1 * address comment * adjust comment * ddress comment * fix func comment * fix loopback adapter gw
- Loading branch information
1 parent
2085f66
commit 7d6ce69
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package hnsclient | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Azure/azure-container-networking/cns" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAdhocAdjustIPConfig(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
ipConfig cns.IPConfiguration | ||
expected cns.IPConfiguration | ||
}{ | ||
{ | ||
name: "expect no change when gw address is not 169.254.128.1", | ||
ipConfig: cns.IPConfiguration{GatewayIPAddress: "169.254.128.3"}, | ||
expected: cns.IPConfiguration{GatewayIPAddress: "169.254.128.3"}, | ||
}, | ||
{ | ||
name: "expect default gw address is set when gw address is 169.254.128.1", | ||
ipConfig: cns.IPConfiguration{GatewayIPAddress: "169.254.128.1"}, | ||
expected: cns.IPConfiguration{GatewayIPAddress: "169.254.128.2"}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
updateGwForLocalIPConfiguration(&tt.ipConfig) | ||
assert.Equal(t, tt.expected.GatewayIPAddress, tt.ipConfig.GatewayIPAddress) | ||
}) | ||
} | ||
} |