@@ -305,178 +305,3 @@ func TestEndpointEnv(t *testing.T) {
305305 })
306306 }
307307}
308-
309- func TestEndpointEquals (t * testing.T ) {
310- tests := []struct {
311- name string
312- first Endpoint
313- second Endpoint
314- areEqual bool
315- }{
316- {
317- name : "equal empty endpoints" ,
318- first : Endpoint {}, second : Endpoint {},
319- areEqual : true ,
320- },
321- {
322- name : "equal ID" ,
323- first : Endpoint {ID : "id" },
324- second : Endpoint {ID : "id" },
325- areEqual : true ,
326- },
327- {
328- name : "unequal ID" ,
329- first : Endpoint {ID : "first" },
330- second : Endpoint {ID : "second" },
331- areEqual : false ,
332- },
333- {
334- name : "equal Target" ,
335- first : Endpoint {Target : "target" },
336- second : Endpoint {Target : "target" },
337- areEqual : true ,
338- },
339- {
340- name : "unequal Target" ,
341- first : Endpoint {Target : "first" },
342- second : Endpoint {Target : "second" },
343- areEqual : false ,
344- },
345- {
346- name : "equal empty Port" ,
347- first : Endpoint {Details : & Port {}},
348- second : Endpoint {Details : & Port {}},
349- areEqual : true ,
350- },
351- {
352- name : "equal Port Name" ,
353- first : Endpoint {Details : & Port {Name : "port_name" }},
354- second : Endpoint {Details : & Port {Name : "port_name" }},
355- areEqual : true ,
356- },
357- {
358- name : "unequal Port Name" ,
359- first : Endpoint {Details : & Port {Name : "first" }},
360- second : Endpoint {Details : & Port {Name : "second" }},
361- areEqual : false ,
362- },
363- {
364- name : "equal Port Port" ,
365- first : Endpoint {Details : & Port {Port : 2379 }},
366- second : Endpoint {Details : & Port {Port : 2379 }},
367- areEqual : true ,
368- },
369- {
370- name : "unequal Port Port" ,
371- first : Endpoint {Details : & Port {Port : 0 }},
372- second : Endpoint {Details : & Port {Port : 1 }},
373- areEqual : false ,
374- },
375- {
376- name : "equal Port Transport" ,
377- first : Endpoint {Details : & Port {Transport : "transport" }},
378- second : Endpoint {Details : & Port {Transport : "transport" }},
379- areEqual : true ,
380- },
381- {
382- name : "unequal Port Transport" ,
383- first : Endpoint {Details : & Port {Transport : "first" }},
384- second : Endpoint {Details : & Port {Transport : "second" }},
385- areEqual : false ,
386- },
387- {
388- name : "equal Port" ,
389- first : Endpoint {
390- ID : EndpointID ("port_id" ),
391- Target : "192.68.73.2" ,
392- Details : & Port {
393- Name : "port_name" ,
394- Pod : Pod {
395- Name : "pod_name" ,
396- Labels : map [string ]string {
397- "label_key" : "label_val" ,
398- },
399- Annotations : map [string ]string {
400- "annotation_1" : "value_1" ,
401- },
402- Namespace : "pod-namespace" ,
403- UID : "pod-uid" ,
404- },
405- Port : 2379 ,
406- Transport : ProtocolTCP ,
407- },
408- },
409- second : Endpoint {
410- ID : EndpointID ("port_id" ),
411- Target : "192.68.73.2" ,
412- Details : & Port {
413- Name : "port_name" ,
414- Pod : Pod {
415- Name : "pod_name" ,
416- Labels : map [string ]string {
417- "label_key" : "label_val" ,
418- },
419- Annotations : map [string ]string {
420- "annotation_1" : "value_1" ,
421- },
422- Namespace : "pod-namespace" ,
423- UID : "pod-uid" ,
424- },
425- Port : 2379 ,
426- Transport : ProtocolTCP ,
427- },
428- },
429- areEqual : true ,
430- },
431- {
432- name : "unequal Port Pod Label" ,
433- first : Endpoint {
434- ID : EndpointID ("port_id" ),
435- Target : "192.68.73.2" ,
436- Details : & Port {
437- Name : "port_name" ,
438- Pod : Pod {
439- Name : "pod_name" ,
440- Labels : map [string ]string {
441- "key_one" : "val_one" ,
442- },
443- Annotations : map [string ]string {
444- "annotation_1" : "value_1" ,
445- },
446- Namespace : "pod-namespace" ,
447- UID : "pod-uid" ,
448- },
449- Port : 2379 ,
450- Transport : ProtocolTCP ,
451- },
452- },
453- second : Endpoint {
454- ID : EndpointID ("port_id" ),
455- Target : "192.68.73.2" ,
456- Details : & Port {
457- Name : "port_name" ,
458- Pod : Pod {
459- Name : "pod_name" ,
460- Labels : map [string ]string {
461- "key_two" : "val_two" ,
462- },
463- Annotations : map [string ]string {
464- "annotation_1" : "value_1" ,
465- },
466- Namespace : "pod-namespace" ,
467- UID : "pod-uid" ,
468- },
469- Port : 2379 ,
470- Transport : ProtocolTCP ,
471- },
472- },
473- areEqual : false ,
474- },
475- }
476- for _ , tt := range tests {
477- t .Run (tt .name , func (t * testing.T ) {
478- require .Equal (t , tt .first .equals (tt .second ), tt .areEqual )
479- require .Equal (t , tt .second .equals (tt .first ), tt .areEqual )
480- })
481- }
482- }
0 commit comments