Index: perf/go/types/types_test.go |
diff --git a/perf/go/types/types_test.go b/perf/go/types/types_test.go |
index 3a130728f1d29b7dd2acc291245e24deba45bb14..2cab1234f71626a9483f816f19a6f6d951ebc16b 100644 |
--- a/perf/go/types/types_test.go |
+++ b/perf/go/types/types_test.go |
@@ -1,6 +1,7 @@ |
package types |
import ( |
+ "net/url" |
"testing" |
"skia.googlesource.com/buildbot.git/perf/go/config" |
@@ -325,3 +326,68 @@ func TestTileTrim(t *testing.T) { |
t.Errorf("Failed to raise error on Trim(0, config.TILE_SIZE+1).") |
} |
} |
+ |
+func TestMatchesWithIgnore(t *testing.T) { |
+ tr := NewPerfTrace() |
+ tr.Params_["p1"] = "v1" |
+ tr.Params_["p2"] = "v2" |
+ |
+ testCases := []struct { |
+ q url.Values |
+ ignore []url.Values |
+ want bool |
+ }{ |
+ // Empty case. |
+ { |
+ q: url.Values{}, |
+ ignore: []url.Values{}, |
+ want: true, |
+ }, |
+ // Only ignore. |
+ { |
+ q: url.Values{}, |
+ ignore: []url.Values{ |
+ url.Values{}, |
+ url.Values{"p2": []string{"v2"}}, |
+ }, |
+ want: false, |
+ }, |
+ // Not match query. |
+ { |
+ q: url.Values{"p1": []string{"bad"}}, |
+ ignore: []url.Values{}, |
+ want: false, |
+ }, |
+ // Match query, fail to match ignore. |
+ { |
+ q: url.Values{"p1": []string{"v1"}}, |
+ ignore: []url.Values{ |
+ url.Values{"p1": []string{"bad"}}, |
+ }, |
+ want: true, |
+ }, |
+ // Match query, and match ignore. |
+ { |
+ q: url.Values{"p1": []string{"v1"}}, |
+ ignore: []url.Values{ |
+ url.Values{"p1": []string{"v1"}}, |
+ }, |
+ want: false, |
+ }, |
+ // Match query, and match one of many ignores. |
+ { |
+ q: url.Values{"p1": []string{"v1"}}, |
+ ignore: []url.Values{ |
+ url.Values{}, |
+ url.Values{"p1": []string{"v1"}}, |
+ }, |
+ want: false, |
+ }, |
+ } |
+ |
+ for _, tc := range testCases { |
+ if got, want := MatchesWithIgnores(tr, tc.q, tc.ignore...), tc.want; got != want { |
+ t.Errorf("MatchesWithIgnores(%v, %v, %v): Got %v Want %v", tr, tc.q, tc.ignore, got, want) |
+ } |
+ } |
+} |