|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/glennliao/apijson-go" |
| 5 | + _ "github.com/glennliao/apijson-go/drivers/executor/goframe" // need import for executor with goframe |
| 6 | + "github.com/glennliao/apijson-go/drivers/framework_goframe" |
| 7 | + "github.com/glennliao/apijson-go/model" |
| 8 | + "github.com/glennliao/apijson-go/query" |
| 9 | + _ "github.com/gogf/gf/contrib/drivers/sqlite/v2" // need import for sqlite |
| 10 | + "github.com/gogf/gf/v2/frame/g" |
| 11 | + "github.com/gogf/gf/v2/os/gctx" |
| 12 | + "testing" |
| 13 | +) |
| 14 | + |
| 15 | +var a *apijson.ApiJson |
| 16 | + |
| 17 | +func init() { |
| 18 | + a = apijson.Load(App) |
| 19 | +} |
| 20 | + |
| 21 | +// notice: import section |
| 22 | +func TestServer(t *testing.T) { |
| 23 | + s := framework_goframe.New(a) |
| 24 | + s.Run() |
| 25 | + // then test in test.http |
| 26 | +} |
| 27 | + |
| 28 | +func TestQuery(t *testing.T) { |
| 29 | + |
| 30 | + ctx := gctx.New() |
| 31 | + q := query.New(ctx, model.Map{ |
| 32 | + "t_user": model.Map{ |
| 33 | + "id": "123", |
| 34 | + "id{}": []string{"123", "456"}, |
| 35 | + "id>": "222", |
| 36 | + "@column": "id,userId", |
| 37 | + }, |
| 38 | + "t_user[]": model.Map{ |
| 39 | + //"userId": "123", |
| 40 | + }, |
| 41 | + //"t_todo": model.Map{}, |
| 42 | + //"_access": model.Map{}, |
| 43 | + }) |
| 44 | + |
| 45 | + q.NoAccessVerify = true //config.AccessVerify |
| 46 | + q.Access = a.Config().Access |
| 47 | + |
| 48 | + result, err := q.Result() |
| 49 | + |
| 50 | + if err != nil { |
| 51 | + panic(err) |
| 52 | + } |
| 53 | + |
| 54 | + g.Dump(result) |
| 55 | + |
| 56 | +} |
| 57 | + |
| 58 | +func BenchmarkName(b *testing.B) { |
| 59 | + for i := 0; i < b.N; i++ { |
| 60 | + ctx := gctx.New() |
| 61 | + |
| 62 | + q := query.New(ctx, model.Map{ |
| 63 | + "Todo": model.Map{}, |
| 64 | + "User": model.Map{}, |
| 65 | + }) |
| 66 | + |
| 67 | + _, err := q.Result() |
| 68 | + if err != nil { |
| 69 | + panic(err) |
| 70 | + } |
| 71 | + } |
| 72 | +} |
0 commit comments