forked from thanos-io/thanos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopts_test.go
53 lines (48 loc) · 910 Bytes
/
opts_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.
package store
import (
"testing"
"github.com/thanos-io/thanos/pkg/testutil"
)
// Refer to https://github.com/prometheus/prometheus/issues/2651.
func TestFindSetMatches(t *testing.T) {
cases := []struct {
pattern string
exp []string
}{
// Simple sets.
{
pattern: "foo|bar|baz",
exp: []string{
"foo",
"bar",
"baz",
},
},
// Simple sets containing escaped characters.
{
pattern: "fo\\.o|bar\\?|\\^baz",
exp: []string{
"fo.o",
"bar?",
"^baz",
},
},
// Simple sets containing special characters without escaping.
{
pattern: "fo.o|bar?|^baz",
exp: nil,
},
{
pattern: "foo\\|bar\\|baz",
exp: []string{
"foo|bar|baz",
},
},
}
for _, c := range cases {
matches := findSetMatches(c.pattern)
testutil.Equals(t, c.exp, matches)
}
}