(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func TestQuery(t *testing.T) { |
| 28 | t.Parallel() |
| 29 | var ( |
| 30 | cls = "MyClass" |
| 31 | m = newFakeGetManager(schema.Schema{}) |
| 32 | errAny = errors.New("any") |
| 33 | ) |
| 34 | params := QueryParams{ |
| 35 | Class: cls, |
| 36 | Limit: ptInt64(10), |
| 37 | } |
| 38 | inputs := QueryInput{ |
| 39 | Class: cls, |
| 40 | Limit: 10, |
| 41 | } |
| 42 | tests := []struct { |
| 43 | class string |
| 44 | name string |
| 45 | param QueryParams |
| 46 | mockedErr *Error |
| 47 | authErr error |
| 48 | wantCode int |
| 49 | mockedDBResponse []search.Result |
| 50 | wantResponse []*models.Object |
| 51 | wantQueryInput QueryInput |
| 52 | wantUsageTracking bool |
| 53 | }{ |
| 54 | { |
| 55 | name: "not found", |
| 56 | class: cls, |
| 57 | param: params, |
| 58 | mockedErr: &Error{Code: StatusNotFound}, |
| 59 | wantCode: StatusNotFound, |
| 60 | wantQueryInput: inputs, |
| 61 | }, |
| 62 | { |
| 63 | name: "forbidden", |
| 64 | class: cls, |
| 65 | param: params, |
| 66 | authErr: errAny, |
| 67 | wantCode: StatusForbidden, |
| 68 | wantQueryInput: inputs, |
| 69 | }, |
| 70 | { |
| 71 | name: "happy path", |
| 72 | class: cls, |
| 73 | param: params, |
| 74 | mockedDBResponse: []search.Result{ |
| 75 | { |
| 76 | ClassName: cls, |
| 77 | Schema: map[string]interface{}{ |
| 78 | "foo": "bar", |
| 79 | }, |
| 80 | Dims: 3, |
| 81 | Dist: 0, |
| 82 | }, |
| 83 | }, |
| 84 | wantResponse: []*models.Object{{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…