Files
query-orchestration/internal/document/list_test.go
T

45 lines
960 B
Go
Raw Normal View History

package document_test
import (
2025-03-05 12:05:46 +00:00
"testing"
"queryorchestration/internal/database/repository"
"queryorchestration/internal/document"
"queryorchestration/internal/serviceconfig"
"github.com/google/uuid"
"github.com/pashagolub/pgxmock/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestListByClientId(t *testing.T) {
2025-06-03 13:52:10 +00:00
ctx := t.Context()
pool, err := pgxmock.NewPool()
require.NoError(t, err)
cfg := &serviceconfig.BaseConfig{}
cfg.DBPool = pool
cfg.DBQueries = repository.New(pool)
svc := document.New(cfg)
clientId := "externalId"
doc := []*document.DocumentSummary{
{
ID: uuid.New(),
Hash: "bucketone",
},
}
pool.ExpectQuery("name: ListDocumentsByClient :many").WithArgs(clientId).
WillReturnRows(
pgxmock.NewRows([]string{"id", "hash"}).
AddRow(doc[0].ID, doc[0].Hash),
)
adoc, err := svc.ListByClient(ctx, clientId)
2025-03-19 11:54:14 +00:00
require.NoError(t, err)
assert.Equal(t, doc, adoc)
}