Kaynağa Gözat

Merge pull request #1276 from kubecost/mmd/filter-empty-startswith-test

Add StartsWith empty string unit test to filters
Michael Dresser 3 yıl önce
ebeveyn
işleme
65c492a84c
1 değiştirilmiş dosya ile 30 ekleme ve 0 silme
  1. 30 0
      pkg/kubecost/allocationfilter_test.go

+ 30 - 0
pkg/kubecost/allocationfilter_test.go

@@ -58,6 +58,36 @@ func Test_AllocationFilterCondition_Matches(t *testing.T) {
 
 			expected: false,
 		},
+		{
+			name: "ClusterID empty StartsWith '' -> true",
+			a: &Allocation{
+				Properties: &AllocationProperties{
+					Cluster: "",
+				},
+			},
+			filter: AllocationFilterCondition{
+				Field: FilterClusterID,
+				Op:    FilterStartsWith,
+				Value: "",
+			},
+
+			expected: true,
+		},
+		{
+			name: "ClusterID nonempty StartsWith '' -> true",
+			a: &Allocation{
+				Properties: &AllocationProperties{
+					Cluster: "abc",
+				},
+			},
+			filter: AllocationFilterCondition{
+				Field: FilterClusterID,
+				Op:    FilterStartsWith,
+				Value: "",
+			},
+
+			expected: true,
+		},
 		{
 			name: "Node Equals -> true",
 			a: &Allocation{