MCPcopy
hub / github.com/weaviate/weaviate / TestQuery

Function TestQuery

usecases/objects/query_test.go:27–156  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func 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{{

Callers

nothing calls this directly

Calls 9

newFakeGetManagerFunction · 0.85
SetErrMethod · 0.80
ErrorfMethod · 0.80
EqualMethod · 0.80
ptInt64Function · 0.70
NewMethod · 0.65
QueryMethod · 0.65
RunMethod · 0.45
ReturnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…