forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tag_test.go
68 lines (65 loc) · 1.35 KB
/
tag_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package influxdb_test
import (
"testing"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
influxTesting "github.com/influxdata/influxdb/v2/testing"
)
func TestTagValid(t *testing.T) {
cases := []struct {
name string
src influxdb.TagRule
err error
}{
{
name: "regular status rule",
src: influxdb.TagRule{
Tag: influxdb.Tag{Key: "k1", Value: "v1"},
Operator: influxdb.Equal,
},
},
{
name: "empty",
src: influxdb.TagRule{},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "tag must contain a key and a value",
},
},
{
name: "empty key",
src: influxdb.TagRule{
Tag: influxdb.Tag{Value: "v1"},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "tag must contain a key and a value",
},
},
{
name: "empty value",
src: influxdb.TagRule{
Tag: influxdb.Tag{Key: "k1"},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "tag must contain a key and a value",
},
},
{
name: "invalid operator",
src: influxdb.TagRule{
Tag: influxdb.Tag{Key: "k1", Value: "v1"},
Operator: influxdb.Operator(-1),
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "Operator is invalid",
},
},
}
for _, c := range cases {
err := c.src.Valid()
influxTesting.ErrorsEqual(t, err, c.err)
}
}