@@ -5,11 +5,14 @@ import (
55"reflect"
66"runtime"
77"testing"
8+
9+ "github.com/Azure/azure-container-networking/common"
810)
911
1012func TestNewMasSource (t * testing.T ) {
1113options := make (map [string ]interface {})
12- mas , _ := newMasSource (options )
14+ options [common .OptEnvironment ] = common .OptEnvironmentMAS
15+ mas , _ := newFileIpamSource (options )
1316
1417if runtime .GOOS == windows {
1518if mas .filePath != defaultWindowsFilePath {
@@ -20,14 +23,35 @@ func TestNewMasSource(t *testing.T) {
2023t .Fatalf ("default file path set incorrectly" )
2124}
2225}
23- if mas .name != "MAS" {
26+
27+ if mas .name != "mas" {
2428t .Fatalf ("mas source Name incorrect" )
2529}
2630}
2731
32+ func TestNewFileIpamSource (t * testing.T ) {
33+ options := make (map [string ]interface {})
34+ options [common .OptEnvironment ] = common .OptEnvironmentFileIPAM
35+ fileIpam , _ := newFileIpamSource (options )
36+
37+ if runtime .GOOS == windows {
38+ if fileIpam .filePath != defaultWindowsFilePath {
39+ t .Fatalf ("default file path set incorrectly" )
40+ }
41+ } else {
42+ if fileIpam .filePath != defaultLinuxFilePath {
43+ t .Fatalf ("default file path set incorrectly" )
44+ }
45+ }
46+
47+ if fileIpam .name != "fileIpam" {
48+ t .Fatalf ("fileIpam source Name incorrect" )
49+ }
50+ }
51+
2852func TestGetSDNInterfaces (t * testing.T ) {
2953const validFileName = "testfiles/masInterfaceConfig.json"
30- const invalidFileName = "mas_test .go"
54+ const invalidFileName = "fileIpam_test .go"
3155const nonexistentFileName = "bad"
3256
3357interfaces , err := getSDNInterfaces (validFileName )
@@ -166,11 +190,11 @@ func TestPopulateAddressSpaceMultipleSDNInterfaces(t *testing.T) {
166190IsPrimary : true ,
167191IPSubnets : []IPSubnet {
168192{
169- Prefix : "0.0.0.0/24" ,
193+ Prefix : "0.0.0.0/24" ,
170194IPAddresses : []IPAddress {},
171195},
172196{
173- Prefix : "0.1.0.0/24" ,
197+ Prefix : "0.1.0.0/24" ,
174198IPAddresses : []IPAddress {},
175199},
176200{
@@ -183,22 +207,22 @@ func TestPopulateAddressSpaceMultipleSDNInterfaces(t *testing.T) {
183207},
184208{
185209MacAddress : "111111111111" ,
186- IsPrimary : false ,
210+ IsPrimary : false ,
187211IPSubnets : []IPSubnet {
188212{
189- Prefix : "1.0.0.0/24" ,
213+ Prefix : "1.0.0.0/24" ,
190214IPAddresses : []IPAddress {},
191215},
192216{
193- Prefix : "1.1.0.0/24" ,
217+ Prefix : "1.1.0.0/24" ,
194218IPAddresses : []IPAddress {},
195219},
196220},
197221},
198222{
199223MacAddress : "222222222222" ,
200- IsPrimary : false ,
201- IPSubnets : []IPSubnet {},
224+ IsPrimary : false ,
225+ IPSubnets : []IPSubnet {},
202226},
203227},
204228}
@@ -263,4 +287,4 @@ func TestPopulateAddressSpaceMultipleSDNInterfaces(t *testing.T) {
263287if pool .Priority != 1 {
264288t .Fatalf ("Incorrect interface priority. expected: %d, actual %d" , 1 , pool .Priority )
265289}
266- }
290+ }
0 commit comments