...
1
16
17 package benchmark
18
19 import (
20 "strings"
21 "testing"
22 )
23
24 func TestLabelFilter(t *testing.T) {
25 empty := ""
26 performance := "performance"
27 fastPerformance := "performance,fast"
28 notFastPerformance := "+performance,-fast"
29 notFast := "-fast"
30
31 testcases := map[string]map[string]bool{
32 empty: {
33 empty: true,
34 performance: true,
35 fastPerformance: true,
36 },
37 performance: {
38 empty: false,
39 performance: true,
40 fastPerformance: true,
41 },
42 fastPerformance: {
43 empty: false,
44 performance: false,
45 fastPerformance: true,
46 },
47 notFast: {
48 empty: true,
49 performance: true,
50 fastPerformance: false,
51 },
52 notFastPerformance: {
53 empty: false,
54 performance: true,
55 fastPerformance: false,
56 },
57 }
58
59 for labelFilter, labelResults := range testcases {
60 t.Run(labelFilter, func(t *testing.T) {
61 for labels, expected := range labelResults {
62 t.Run(labels, func(t *testing.T) {
63 actual := enabled(labelFilter, strings.Split(labels, ",")...)
64 if actual != expected {
65 t.Errorf("expected enabled to be %v, got %v", expected, actual)
66 }
67 })
68 }
69 })
70 }
71 }
72
View as plain text