forked from cbrake/influxdbhelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_test.go
38 lines (35 loc) · 1.13 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
package influxdbhelper
import "testing"
func TestTag(t *testing.T) {
data := []struct {
fieldTag string
structFieldName string
fieldName string
isTag bool
isField bool
}{
{"", "Test", "Test", false, true},
{"", "Test", "Test", false, true},
{",tag", "Test", "Test", true, false},
{",field,tag", "Test", "Test", true, true},
{",tag,field", "Test", "Test", true, true},
{",field", "Test", "Test", false, true},
{"test", "Test", "test", false, true},
{"test,tag", "Test", "test", true, false},
{"test,field,tag", "Test", "test", true, true},
{"test,tag,field", "Test", "test", true, true},
{"test,field", "Test", "test", false, true},
}
for _, testData := range data {
fieldData := getInfluxFieldTagData(testData.structFieldName, testData.fieldTag)
if fieldData.fieldName != testData.fieldName {
t.Errorf("%v != %v", fieldData.fieldName, testData.fieldName)
}
if fieldData.isField != testData.isField {
t.Errorf("%v != %v", fieldData.isField, testData.isField)
}
if fieldData.isTag != testData.isTag {
t.Errorf("%v != %v", fieldData.isTag, testData.isTag)
}
}
}