Skip to content

Commit

Permalink
fix unittest
Browse files Browse the repository at this point in the history
Signed-off-by: zwwhdls <zww@hdls.me>
  • Loading branch information
zwwhdls committed Dec 17, 2024
1 parent a50279f commit e397d12
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
38 changes: 13 additions & 25 deletions pkg/store/meili/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,39 +113,31 @@ func (m *MockClient) FilterDocuments(ctx context.Context, filter *doc.DocumentFi
all := len(aq.AttrQueries)
matched := true
for _, q := range aq.AttrQueries {
if q.Attr == "entryId" {
switch q.Attr {
case "entryId":
all -= 1
if !match(q, attr.EntryId) {
matched = false
continue
}
}
if q.Attr == "namespace" {
case "namespace":
all -= 1
if !match(q, attr.Namespace) {
matched = false
continue
}
}
if q.Attr == "key" {
case "key":
all -= 1
if !match(q, attr.Key) {
matched = false
continue
}
}
if q.Attr == "value" {
case "value":
all -= 1
if !match(q, attr.Value) {
matched = false
continue
}
}
if q.Attr == "kind" {
case "kind":
all -= 1
if !match(q, attr.Kind) {
matched = false
continue
}
}
}
Expand All @@ -160,6 +152,8 @@ func (m *MockClient) FilterDocuments(ctx context.Context, filter *doc.DocumentFi
Option: "IN",
Value: entryId,
})
} else {
return nil, nil
}
}

Expand All @@ -168,32 +162,26 @@ func (m *MockClient) FilterDocuments(ctx context.Context, filter *doc.DocumentFi
matched := true
all := len(query.AttrQueries)
for _, q := range query.AttrQueries {
if q.Attr == "entryId" {
switch q.Attr {
case "entryId":
all -= 1
if !match(q, d.EntryId) {
matched = false
continue
}
}
if q.Attr == "namespace" {
case "namespace":
all -= 1
if !match(q, d.Namespace) {
matched = false
continue
}
}
if q.Attr == "id" {
case "id":
all -= 1
if !match(q, d.Id) {
matched = false
continue
}
}
if q.Attr == "kind" {
case "kind":
all -= 1
if !match(q, d.Kind) {
matched = false
continue
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/meili/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (d *DocumentAttrList) FromModel(doc *doc.Document) *DocumentAttrList {
Namespace: doc.Namespace,
EntryId: fmt.Sprintf("%d", doc.EntryId),
Key: "parentId",
Value: fmt.Sprintf("%d", *doc.ParentEntryID),
Value: *doc.ParentEntryID,
})
}
mark := false
Expand Down

0 comments on commit e397d12

Please sign in to comment.