feat(crm): route crm search through meilisearch
This commit is contained in:
@@ -24,11 +24,15 @@ type mockSearchRepo struct {
|
||||
msgTotal int64
|
||||
msgErr error
|
||||
|
||||
contacts []model.Contact
|
||||
contacts []model.Contact
|
||||
contactTotal int64
|
||||
contactErr error
|
||||
|
||||
articles []model.Article
|
||||
companies []model.Company
|
||||
companyTotal int64
|
||||
companyErr error
|
||||
|
||||
articles []model.Article
|
||||
articleTotal int64
|
||||
articleErr error
|
||||
}
|
||||
@@ -45,6 +49,10 @@ func (m *mockSearchRepo) SearchContacts(ctx context.Context, accountID uint, que
|
||||
return m.contacts, m.contactTotal, m.contactErr
|
||||
}
|
||||
|
||||
func (m *mockSearchRepo) SearchCompanies(ctx context.Context, accountID uint, query string, filter *search.SearchFilter) ([]model.Company, int64, error) {
|
||||
return m.companies, m.companyTotal, m.companyErr
|
||||
}
|
||||
|
||||
func (m *mockSearchRepo) SearchArticles(ctx context.Context, accountID uint, query string, filter *search.SearchFilter) ([]model.Article, int64, error) {
|
||||
return m.articles, m.articleTotal, m.articleErr
|
||||
}
|
||||
@@ -263,8 +271,8 @@ func TestSearchHandler_SearchMessages_ServiceError(t *testing.T) {
|
||||
|
||||
func TestSearchHandler_SearchContacts_Success(t *testing.T) {
|
||||
repo := &mockSearchRepo{
|
||||
contacts: []model.Contact{makeContact(1, "Alice")},
|
||||
contactTotal: 1,
|
||||
contacts: []model.Contact{makeContact(1, "Alice")},
|
||||
contactTotal: 1,
|
||||
}
|
||||
svc := search.NewSearchService(repo)
|
||||
handler := NewSearchHandler(svc)
|
||||
@@ -315,8 +323,8 @@ func TestSearchHandler_SearchContacts_ServiceError(t *testing.T) {
|
||||
|
||||
func TestSearchHandler_SearchArticles_Success(t *testing.T) {
|
||||
repo := &mockSearchRepo{
|
||||
articles: []model.Article{makeArticle(1, 1, "FAQ Guide", "desc", "content", "published")},
|
||||
articleTotal: 1,
|
||||
articles: []model.Article{makeArticle(1, 1, "FAQ Guide", "desc", "content", "published")},
|
||||
articleTotal: 1,
|
||||
}
|
||||
svc := search.NewSearchService(repo)
|
||||
handler := NewSearchHandler(svc)
|
||||
@@ -361,4 +369,4 @@ func TestSearchHandler_SearchArticles_ServiceError(t *testing.T) {
|
||||
router.ServeHTTP(w, req)
|
||||
|
||||
assert.Equal(t, http.StatusUnprocessableEntity, w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user