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

48 lines
1.1 KiB
Go
Raw Normal View History

package document_test
import (
"context"
2025-03-05 12:05:46 +00:00
"testing"
"queryorchestration/internal/database"
"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) {
ctx := context.Background()
pool, err := pgxmock.NewPool()
require.NoError(t, err)
cfg := &serviceconfig.BaseConfig{}
cfg.DBPool = pool
cfg.DBQueries = repository.New(pool)
svc := document.New(cfg)
clientId := uuid.New()
doc := []*document.DocumentInList{
{
ID: uuid.New(),
Bucket: "bucketone",
Key: "keyone",
},
}
pool.ExpectQuery("name: ListDocumentsByClientId :many").WithArgs(database.MustToDBUUID(clientId)).
WillReturnRows(
pgxmock.NewRows([]string{"id", "bucket", "key"}).
AddRow(database.MustToDBUUID(doc[0].ID), doc[0].Bucket, doc[0].Key),
)
adoc, err := svc.ListByClientId(ctx, clientId)
assert.NoError(t, err)
assert.Equal(t, doc, adoc)
}