mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 04:01:34 +00:00
Some checks failed
- Updated database models and repositories to replace uint IDs with UUIDs. - Modified test fixtures to generate and use UUIDs for authors, translations, users, and works. - Adjusted mock implementations to align with the new UUID structure. - Ensured all relevant functions and methods are updated to handle UUIDs correctly. - Added necessary imports for UUID handling in various files.
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package search
|
|
|
|
import (
|
|
"context"
|
|
"github.com/stretchr/testify/assert"
|
|
"tercul/internal/domain"
|
|
domainsearch "tercul/internal/domain/search"
|
|
"testing"
|
|
)
|
|
|
|
func TestWeaviateWrapper_Search(t *testing.T) {
|
|
mockWrapper := new(MockWeaviateWrapper)
|
|
expectedResults := &domainsearch.SearchResults{
|
|
Results: []domainsearch.SearchResultItem{
|
|
{
|
|
Type: "Work",
|
|
Entity: domain.Work{
|
|
Title: "Work 1",
|
|
Description: "alpha beta",
|
|
TranslatableModel: domain.TranslatableModel{Language: "en"},
|
|
},
|
|
Score: 0.95,
|
|
},
|
|
},
|
|
TotalResults: 1,
|
|
Limit: 1,
|
|
Offset: 0,
|
|
}
|
|
params := domainsearch.SearchParams{
|
|
Query: "alpha",
|
|
Mode: domainsearch.SearchModeHybrid,
|
|
Filters: domainsearch.SearchFilters{
|
|
Languages: []string{"en"},
|
|
},
|
|
Limit: 1,
|
|
Offset: 0,
|
|
}
|
|
|
|
mockWrapper.On("Search", context.Background(), params).Return(expectedResults, nil)
|
|
|
|
results, err := mockWrapper.Search(context.Background(), params)
|
|
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, results)
|
|
assert.Equal(t, 1, len(results.Results))
|
|
assert.Equal(t, "Work", results.Results[0].Type)
|
|
work := results.Results[0].Entity.(domain.Work)
|
|
assert.Equal(t, "Work 1", work.Title)
|
|
|
|
mockWrapper.AssertExpectations(t)
|
|
}
|