(t *testing.T)
| 187 | } |
| 188 | |
| 189 | func TestQueryCountEmptyNames(t *testing.T) { |
| 190 | tests := []struct { |
| 191 | in, out, failure string |
| 192 | }{ |
| 193 | {in: `{q(func: has(name)) @filter(eq(name, "")) {count(uid)}}`, |
| 194 | out: `{"data":{"q": [{"count":2}]}}`}, |
| 195 | {in: `{q(func: has(name)) @filter(gt(name, "")) {count(uid)}}`, |
| 196 | out: `{"data":{"q": [{"count":57}]}}`}, |
| 197 | {in: `{q(func: has(name)) @filter(ge(name, "")) {count(uid)}}`, |
| 198 | out: `{"data":{"q": [{"count":59}]}}`}, |
| 199 | {in: `{q(func: has(name)) @filter(lt(name, "")) {count(uid)}}`, |
| 200 | out: `{"data":{"q": [{"count":0}]}}`}, |
| 201 | {in: `{q(func: has(name)) @filter(le(name, "")) {count(uid)}}`, |
| 202 | out: `{"data":{"q": [{"count":2}]}}`}, |
| 203 | {in: `{q(func: has(name)) @filter(anyofterms(name, "")) {count(uid)}}`, |
| 204 | out: `{"data":{"q": [{"count":2}]}}`}, |
| 205 | {in: `{q(func: has(name)) @filter(allofterms(name, "")) {count(uid)}}`, |
| 206 | out: `{"data":{"q": [{"count":2}]}}`}, |
| 207 | // NOTE: match with empty string filters values greater than the max distance. |
| 208 | {in: `{q(func: has(name)) @filter(match(name, "", 8)) {count(uid)}}`, |
| 209 | out: `{"data":{"q": [{"count":39}]}}`}, |
| 210 | {in: `{q(func: has(name)) @filter(uid_in(name, "")) {count(uid)}}`, |
| 211 | failure: `Value "" in uid_in is not a number`}, |
| 212 | } |
| 213 | for _, tc := range tests { |
| 214 | js, err := processQuery(context.Background(), t, tc.in) |
| 215 | if tc.failure != "" { |
| 216 | require.Error(t, err) |
| 217 | require.Contains(t, err.Error(), tc.failure) |
| 218 | } else { |
| 219 | require.NoError(t, err) |
| 220 | require.JSONEq(t, tc.out, js) |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | func TestQueryEmptyRoomsWithTermIndex(t *testing.T) { |
| 226 | query := `{ |
nothing calls this directly
no test coverage detected