浏览代码

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

Add StartsWith empty string unit test to filters
Michael Dresser 4 年之前
父节点
当前提交
65c492a84c
共有 1 个文件被更改,包括 30 次插入0 次删除
  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{