-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathrows_test.go
More file actions
64 lines (61 loc) · 1.69 KB
/
Copy pathrows_test.go
File metadata and controls
64 lines (61 loc) · 1.69 KB
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
package models_test
import (
"testing"
"github.com/influxdata/influxdb/models"
"github.com/stretchr/testify/require"
)
func TestRow_SameSeries(t *testing.T) {
for _, tt := range []struct {
name string
a, b models.Row
want bool
}{
{
name: "same name and tags",
a: models.Row{Name: "cpu", Tags: map[string]string{"host": "a"}},
b: models.Row{Name: "cpu", Tags: map[string]string{"host": "a"}},
want: true,
},
{
name: "different name",
a: models.Row{Name: "cpu"},
b: models.Row{Name: "mem"},
want: false,
},
{
name: "different tags",
a: models.Row{Name: "cpu", Tags: map[string]string{"host": "a"}},
b: models.Row{Name: "cpu", Tags: map[string]string{"host": "b"}},
want: false,
},
{
name: "same grouping keys",
a: models.Row{Name: "cpu", GroupingKeys: []string{"month", "year"}},
b: models.Row{Name: "cpu", GroupingKeys: []string{"month", "year"}},
want: true,
},
{
name: "different grouping keys",
a: models.Row{Name: "cpu", GroupingKeys: []string{"year"}},
b: models.Row{Name: "cpu", GroupingKeys: []string{"month"}},
want: false,
},
{
name: "grouping keys only on one side",
a: models.Row{Name: "cpu", GroupingKeys: []string{"year"}},
b: models.Row{Name: "cpu"},
want: false,
},
{
name: "grouping keys prefix of the other",
a: models.Row{Name: "cpu", GroupingKeys: []string{"year"}},
b: models.Row{Name: "cpu", GroupingKeys: []string{"month", "year"}},
want: false,
},
} {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.want, tt.a.SameSeries(&tt.b))
require.Equal(t, tt.want, tt.b.SameSeries(&tt.a), "SameSeries must be symmetric")
})
}
}