tercul-backend/internal/platform/search/weaviate_wrapper_test.go
google-labs-jules[bot] 0237e44b1f feat: Implement full-text search service
This commit implements the full-text search service using Weaviate. It replaces the stub implementation with a fully functional search service that supports hybrid and BM25 search modes.

The new implementation includes:
- Support for hybrid and BM25 search modes.
- Transformation of Weaviate search results into domain entities.
- Unit tests using a mock Weaviate wrapper to ensure the implementation is correct and to avoid environmental issues in the test pipeline.
2025-11-29 00:55:05 +00:00

39 lines
961 B
Go

package search
import (
"context"
"testing"
"tercul/internal/domain"
domainsearch "tercul/internal/domain/search"
"github.com/stretchr/testify/assert"
)
func TestWeaviateWrapper_Search(t *testing.T) {
mockWrapper := new(MockWeaviateWrapper)
expectedResults := &domain.SearchResults{
Works: []domain.Work{
{Title: "Work 1", Description: "alpha beta", TranslatableModel: domain.TranslatableModel{Language: "en"}},
},
}
params := domainsearch.SearchParams{
Query: "alpha",
Mode: domainsearch.SearchModeHybrid,
Filters: domain.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.Works))
assert.Equal(t, "Work 1", results.Works[0].Title)
mockWrapper.AssertExpectations(t)
}