forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tag_test.go
67 lines (64 loc) · 1.3 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
package influxdb_test
import (
"testing"
"github.com/influxdata/influxdb"
influxTesting "github.com/influxdata/influxdb/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: &influxdb.Error{
Code: influxdb.EInvalid,
Msg: "tag must contain a key and a value",
},
},
{
name: "empty key",
src: influxdb.TagRule{
Tag: influxdb.Tag{Value: "v1"},
},
err: &influxdb.Error{
Code: influxdb.EInvalid,
Msg: "tag must contain a key and a value",
},
},
{
name: "empty value",
src: influxdb.TagRule{
Tag: influxdb.Tag{Key: "k1"},
},
err: &influxdb.Error{
Code: influxdb.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: &influxdb.Error{
Code: influxdb.EInvalid,
Msg: "Operator is invalid",
},
},
}
for _, c := range cases {
err := c.src.Valid()
influxTesting.ErrorsEqual(t, err, c.err)
}
}