-
Notifications
You must be signed in to change notification settings - Fork 130
/
query_test.go
51 lines (45 loc) · 1.65 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package search
import (
"fmt"
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
type ApplicationQuery struct {
Id string `search:"type:icontains;column:id;table:receipt" form:"id"`
Domain string `search:"type:icontains;column:domain;table:receipt" form:"domain"`
Version string `search:"type:exact;column:version;table:receipt" form:"version"`
Status []int `search:"type:in;column:status;table:receipt" form:"status"`
Start time.Time `search:"type:gte;column:created_at;table:receipt" form:"start"`
End time.Time `search:"type:lte;column:created_at;table:receipt" form:"end"`
TestJoin `search:"type:left;on:id:receipt_id;table:receipt_goods;join:receipts"`
NotNeed string `search:"-"`
ApplicationOrder
}
type ApplicationOrder struct {
IdOrder string `search:"type:order;column:id;table:receipt" form:"id_order"`
}
type TestJoin struct {
PaymentAccount string `search:"type:icontains;column:payment_account;table:receipts" form:"payment_account"`
}
func TestResolveSearchQuery(t *testing.T) {
// Only pass t into top-level Convey calls
Convey("Given some integer with a starting value", t, func() {
d := ApplicationQuery{
Id: "aaa",
Domain: "bbb",
Version: "ccc",
Status: []int{1, 2},
Start: time.Now().Add(-8 * time.Hour),
End: time.Now(),
ApplicationOrder: ApplicationOrder{IdOrder: "desc"},
TestJoin: TestJoin{PaymentAccount: "1212"},
}
condition := &GormCondition{
GormPublic: GormPublic{},
Join: make([]*GormJoin, 0),
}
ResolveSearchQuery("mysql", d, condition)
fmt.Println(condition)
})
}