MCPcopy Index your code
hub / github.com/micro/go-micro / TestApplyQueryOptions

Function TestApplyQueryOptions

model/model_test.go:111–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

109}
110
111func TestApplyQueryOptions(t *testing.T) {
112 q := ApplyQueryOptions(
113 Where("name", "Alice"),
114 WhereOp("age", ">", 20),
115 OrderDesc("name"),
116 Limit(10),
117 Offset(5),
118 )
119
120 if len(q.Filters) != 2 {
121 t.Fatalf("expected 2 filters, got %d", len(q.Filters))
122 }
123 if q.Filters[0].Field != "name" || q.Filters[0].Op != "=" || q.Filters[0].Value != "Alice" {
124 t.Errorf("unexpected filter 0: %+v", q.Filters[0])
125 }
126 if q.Filters[1].Field != "age" || q.Filters[1].Op != ">" {
127 t.Errorf("unexpected filter 1: %+v", q.Filters[1])
128 }
129 if q.OrderBy != "name" || !q.Desc {
130 t.Errorf("expected order by name desc, got %q desc=%v", q.OrderBy, q.Desc)
131 }
132 if q.Limit != 10 {
133 t.Errorf("expected limit 10, got %d", q.Limit)
134 }
135 if q.Offset != 5 {
136 t.Errorf("expected offset 5, got %d", q.Offset)
137 }
138}

Callers

nothing calls this directly

Calls 8

ApplyQueryOptionsFunction · 0.85
WhereFunction · 0.85
WhereOpFunction · 0.85
OrderDescFunction · 0.85
LimitFunction · 0.85
OffsetFunction · 0.85
FatalfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…