forked from go-rel/rel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroup_query_test.go
34 lines (27 loc) · 913 Bytes
/
group_query_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
package rel_test
import (
"testing"
"github.com/go-rel/rel"
"github.com/stretchr/testify/assert"
)
func TestGroup(t *testing.T) {
assert.Equal(t, rel.GroupQuery{
Fields: []string{"status"},
}, rel.NewGroup("status"))
}
func TestGroup_Having(t *testing.T) {
q := rel.GroupQuery{
Fields: []string{"status"},
Filter: rel.Ne("status", "expired"),
}
assert.Equal(t, q, rel.NewGroup("status").Having(rel.Ne("status", "expired")))
assert.Equal(t, q, rel.NewGroup("status").Where(rel.Ne("status", "expired")))
}
func TestGroup_OrHaving(t *testing.T) {
q := rel.GroupQuery{
Fields: []string{"status"},
Filter: rel.Ne("status", "expired").OrNotNil("deleted_at"),
}
assert.Equal(t, q, rel.NewGroup("status").Having(rel.Ne("status", "expired")).OrHaving(rel.NotNil("deleted_at")))
assert.Equal(t, q, rel.NewGroup("status").Where(rel.Ne("status", "expired")).OrWhere(rel.NotNil("deleted_at")))
}