Files
query-orchestration/internal/document/list_test.go
T
Michael McGuinness 6648cdf1cb Merged in feature/clientexternalid (pull request #99)
Client External ID

* normalizeexternalid

* cleanopenapi

* cleanopenapi

* changingpublic

* noprecommit

* testing

* precommit

* processtest

* nodb

* tests

* tests
2025-03-11 16:31:06 +00:00

48 lines
1.1 KiB
Go

package document_test
import (
"context"
"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 := "externalId"
doc := []*document.DocumentInList{
{
ID: uuid.New(),
Bucket: "bucketone",
Key: "keyone",
},
}
pool.ExpectQuery("name: ListDocumentsByClientExternalId :many").WithArgs(clientId).
WillReturnRows(
pgxmock.NewRows([]string{"id", "bucket", "key"}).
AddRow(database.MustToDBUUID(doc[0].ID), doc[0].Bucket, doc[0].Key),
)
adoc, err := svc.ListByClientExternalId(ctx, clientId)
assert.NoError(t, err)
assert.Equal(t, doc, adoc)
}