Add unit test for Has in pkg/labels/labels.go (#7039)
This PR is about adding a unit test for Has in pkg/labels/labels.go. Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>
This commit is contained in:
		
							parent
							
								
									f494426f73
								
							
						
					
					
						commit
						002b391dfc
					
				|  | @ -453,3 +453,35 @@ func TestLabels_Compare(t *testing.T) { | ||||||
| 		testutil.Equals(t, test.expected, got, "unexpected comparison result for test case %d", i) | 		testutil.Equals(t, test.expected, got, "unexpected comparison result for test case %d", i) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func TestLabels_Has(t *testing.T) { | ||||||
|  | 	tests := []struct { | ||||||
|  | 		input    string | ||||||
|  | 		expected bool | ||||||
|  | 	}{ | ||||||
|  | 		{ | ||||||
|  | 			input:    "foo", | ||||||
|  | 			expected: false, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			input:    "aaa", | ||||||
|  | 			expected: true, | ||||||
|  | 		}, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	labelsSet := Labels{ | ||||||
|  | 		{ | ||||||
|  | 			Name:  "aaa", | ||||||
|  | 			Value: "111", | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			Name:  "bbb", | ||||||
|  | 			Value: "222", | ||||||
|  | 		}, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	for i, test := range tests { | ||||||
|  | 		got := labelsSet.Has(test.input) | ||||||
|  | 		testutil.Equals(t, test.expected, got, "unexpected comparison result for test case %d", i) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue