@@ -217,6 +217,95 @@ var efoNetworkFirstLevelStructKeysEmpty = map[string]interface{}{
217
217
"wireless" : []interface {}{},
218
218
}
219
219
220
+ var rdNetwork2ndLevelStructsEmpty = map [string ]interface {}{
221
+ "name" : "SampleName" ,
222
+ "id" : "Sample ID" ,
223
+ "description" : "Sample Description" ,
224
+ "title" : "Sample Title" ,
225
+ "dns_list" : []interface {}{
226
+ map [string ]interface {}{
227
+ "addrs" : []interface {}{},
228
+ "hostname" : "www.example.com" ,
229
+ },
230
+ map [string ]interface {}{
231
+ "addrs" : []interface {}{},
232
+ "hostname" : "www.example2.com" ,
233
+ },
234
+ },
235
+ "enterprise_default" : true ,
236
+ "ip" : []interface {}{
237
+ map [string ]interface {}{
238
+ "dhcp" : "NETWORK_DHCP_TYPE_CLIENT" ,
239
+ "dhcp_range" : []interface {}{},
240
+ "dns" : []interface {}{},
241
+ "domain" : "example.com" ,
242
+ "gateway" : "10.10.1.1" ,
243
+ "mask" : "255.255.255.0" ,
244
+ "ntp" : "10.10.1.1" ,
245
+ "subnet" : "10.1.1.0/16" ,
246
+ },
247
+ },
248
+ "kind" : "NETWORK_KIND_V4" ,
249
+ "project_id" : "sample-project-id" ,
250
+ "proxy" : []interface {}{
251
+ map [string ]interface {}{
252
+ "exceptions" : "exception1" ,
253
+ "network_proxy" : true ,
254
+ "network_proxy_certs" : []interface {}{},
255
+ "network_proxy_url" : "www.example.com" ,
256
+ "pacfile" : "testpacfile" ,
257
+ "proxy" : []interface {}{},
258
+ },
259
+ },
260
+ "revision" : []interface {}{map [string ]interface {}{
261
+ "created_at" : "2020-12-15T06:21:24Z" ,
262
+ "created_by" :
"[email protected] " ,
263
+ "curr" : "1" ,
264
+ "updated_at" : "2020-12-15T06:21:24Z" ,
265
+ "updated_by" :
"[email protected] " ,
266
+ }},
267
+ "wireless" : []interface {}{
268
+ map [string ]interface {}{
269
+ // In reality, we can have either Cellular cfg or wifi cfg depending
270
+ // on type - not both. But for unit test, lets populate both structures.
271
+ "cellular_cfg" : []interface {}{},
272
+ "type" : "NETWORK_WIRELESS_TYPE_WIFI" ,
273
+ "wifi_cfg" : []interface {}{},
274
+ },
275
+ },
276
+ }
277
+ var efoNetwork2ndLevelStructsEmpty = map [string ]interface {}{
278
+ "name" : rdNetworkFullCfg ["name" ],
279
+ "id" : rdNetworkFullCfg ["id" ],
280
+ "description" : rdNetworkFullCfg ["description" ],
281
+ "title" : rdNetworkFullCfg ["title" ],
282
+ "dns_list" : rdNetworkFullCfg ["dns_list" ],
283
+ "enterprise_default" : rdNetworkFullCfg ["enterprise_default" ],
284
+ "ip" : rdNetworkFullCfg ["ip" ],
285
+ "kind" : rdNetworkFullCfg ["kind" ],
286
+ "project_id" : rdNetworkFullCfg ["project_id" ],
287
+ "proxy" : rdNetworkFullCfg ["proxy" ],
288
+ "revision" : []interface {}{},
289
+ "wireless" : []interface {}{
290
+ map [string ]interface {}{
291
+ // In reality, we can have either Cellular cfg or wifi cfg depending
292
+ // on type - not both. But for unit test, lets populate both structures.
293
+ "cellular_cfg" : []interface {}{
294
+ map [string ]interface {}{
295
+ "apn" : "Sample APN" ,
296
+ },
297
+ },
298
+ "type" : "NETWORK_WIRELESS_TYPE_WIFI" ,
299
+ "wifi_cfg" : []interface {}{
300
+ map [string ]interface {}{
301
+ "key_scheme" : "NETWORK_WIFIKEY_SCHEME_WPAPSK" ,
302
+ "priority" : 10 ,
303
+ "wifi_ssid" : "Sample Wifi SSID" ,
304
+ },
305
+ },
306
+ },
307
+ },
308
+ }
220
309
// In each test case, call rdXXX to get the appropriate config struct,
221
310
// feed it to flattenXXX, verify output of flattenXXX is same as input
222
311
func TestRDNetworkConfig (t * testing.T ) {
@@ -251,6 +340,14 @@ func TestRDNetworkConfig(t *testing.T) {
251
340
expectError : false ,
252
341
expectedFlattenedOutput : efoNetworkFirstLevelStructKeysEmpty ,
253
342
},
343
+ /*
344
+ {
345
+ input: rdNetwork2ndLevelStructsEmpty,
346
+ description: "2nd level keys Empty",
347
+ expectError: false,
348
+ expectedFlattenedOutput: efoNetwork2ndLevelStructsEmpty,
349
+ },
350
+ */
254
351
}
255
352
256
353
for _ , c := range cases {
@@ -286,7 +383,8 @@ func TestRDNetworkConfig(t *testing.T) {
286
383
"Error matching Flattened output and input.\n " +
287
384
"Output: %#v\n " +
288
385
"Input : %#v\n " +
289
- "Diff: %#v" , c .description , out , c .expectedFlattenedOutput , diff )
386
+ "Diff ( expected vs actual): %#v" , c .description , out ,
387
+ c .expectedFlattenedOutput , diff )
290
388
}
291
389
}
292
390
}
0 commit comments