(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestUnmarshalQuery(t *testing.T) { //nolint:tparallel |
| 17 | t.Parallel() |
| 18 | |
| 19 | cases := []struct { |
| 20 | Name string |
| 21 | Input string |
| 22 | Expected Query |
| 23 | Error error |
| 24 | }{ |
| 25 | { |
| 26 | "Parse a simple query", |
| 27 | `{ "domain": ["example.com", "example.at"] }`, |
| 28 | Query{ |
| 29 | "domain": []Matcher{ |
| 30 | { |
| 31 | Equal: "example.com", |
| 32 | }, |
| 33 | { |
| 34 | Equal: "example.at", |
| 35 | }, |
| 36 | }, |
| 37 | }, |
| 38 | nil, |
| 39 | }, |
| 40 | { |
| 41 | "Parse a more complex query", |
| 42 | ` |
| 43 | { |
| 44 | "domain": [ |
| 45 | { |
| 46 | "$in": [ |
| 47 | "example.at", |
| 48 | "example.com" |
| 49 | ] |
| 50 | }, |
| 51 | { |
| 52 | "$like": "microsoft.%" |
| 53 | } |
| 54 | ], |
| 55 | "path": [ |
| 56 | "/bin/ping", |
| 57 | { |
| 58 | "$notin": [ |
| 59 | "/sbin/ping", |
| 60 | "/usr/sbin/ping" |
| 61 | ] |
| 62 | } |
| 63 | ] |
| 64 | } |
| 65 | `, |
| 66 | Query{ |
| 67 | "domain": []Matcher{ |
| 68 | { |
| 69 | In: []interface{}{ |
| 70 | "example.at", |
| 71 | "example.com", |
| 72 | }, |
| 73 | }, |