@@ -205,3 +205,108 @@ func TestBuildNSXVPC(t *testing.T) {
205205		})
206206	}
207207}
208+ 
209+ func  Test_combineVPCIDAndLBSID (t  * testing.T ) {
210+ 	type  args  struct  {
211+ 		vpcID  string 
212+ 		lbsID  string 
213+ 	}
214+ 	tests  :=  []struct  {
215+ 		name  string 
216+ 		args  args 
217+ 		want  string 
218+ 	}{
219+ 		{
220+ 			name : "pass" ,
221+ 			args : args {
222+ 				vpcID : "fakeVpc" ,
223+ 				lbsID : "fakeLbs" ,
224+ 			},
225+ 			want : "fakeVpc_fakeLbs" ,
226+ 		},
227+ 	}
228+ 	for  _ , tt  :=  range  tests  {
229+ 		t .Run (tt .name , func (t  * testing.T ) {
230+ 			if  got  :=  combineVPCIDAndLBSID (tt .args .vpcID , tt .args .lbsID ); got  !=  tt .want  {
231+ 				t .Errorf ("combineVPCIDAndLBSID() = %v, want %v" , got , tt .want )
232+ 			}
233+ 		})
234+ 	}
235+ }
236+ 
237+ func  Test_generateLBSKey (t  * testing.T ) {
238+ 	emptyPath  :=  "" 
239+ 	emptyVpcPath  :=  "/fake/path/empty/vpc/" 
240+ 	okPath  :=  "/fake/path/vpc/fake-vpc" 
241+ 	okId  :=  "fake-id" 
242+ 	type  args  struct  {
243+ 		lbs  model.LBService 
244+ 	}
245+ 	tests  :=  []struct  {
246+ 		name     string 
247+ 		args     args 
248+ 		want     string 
249+ 		wantErr  bool 
250+ 	}{
251+ 		{
252+ 			name : "nil connectivity path" ,
253+ 			args : args {
254+ 				lbs : model.LBService {ConnectivityPath : nil },
255+ 			},
256+ 			want :    "" ,
257+ 			wantErr : true ,
258+ 		},
259+ 		{
260+ 			name : "empty connectivity path" ,
261+ 			args : args {
262+ 				lbs : model.LBService {ConnectivityPath : & emptyPath },
263+ 			},
264+ 			want :    "" ,
265+ 			wantErr : true ,
266+ 		},
267+ 		{
268+ 			name : "empty vpc id" ,
269+ 			args : args {
270+ 				lbs : model.LBService {ConnectivityPath : & emptyVpcPath },
271+ 			},
272+ 			want :    "" ,
273+ 			wantErr : true ,
274+ 		},
275+ 		{
276+ 			name : "nil lbs id" ,
277+ 			args : args {
278+ 				lbs : model.LBService {ConnectivityPath : & okPath , Id : nil },
279+ 			},
280+ 			want :    "" ,
281+ 			wantErr : true ,
282+ 		},
283+ 		{
284+ 			name : "empty lbs id" ,
285+ 			args : args {
286+ 				lbs : model.LBService {ConnectivityPath : & okPath , Id : & emptyPath },
287+ 			},
288+ 			want :    "" ,
289+ 			wantErr : true ,
290+ 		},
291+ 		{
292+ 			name : "empty lbs id" ,
293+ 			args : args {
294+ 				lbs : model.LBService {ConnectivityPath : & okPath , Id : & okId },
295+ 			},
296+ 			want :    "fake-vpc_fake-id" ,
297+ 			wantErr : false ,
298+ 		},
299+ 	}
300+ 	for  _ , tt  :=  range  tests  {
301+ 		t .Run (tt .name , func (t  * testing.T ) {
302+ 			got , err  :=  generateLBSKey (tt .args .lbs )
303+ 			if  (err  !=  nil ) !=  tt .wantErr  {
304+ 				t .Errorf ("generateLBSKey() error = %v, wantErr %v" , err , tt .wantErr )
305+ 				return 
306+ 			}
307+ 			if  got  !=  tt .want  {
308+ 				t .Errorf ("generateLBSKey() = %v, want %v" , got , tt .want )
309+ 			}
310+ 		})
311+ 	}
312+ }
0 commit comments