62886dbba8
Remove Job * removejob * rmjob * sync * cleanup * precommit * startslow * startslow * startslow * openapi * clean * test * scripts * littlecleanercmds * mermaid
48 lines
1.1 KiB
Go
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 := 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)
|
|
}
|