7ce7c9df4d
Feature/ecr * nosave * repo * awscli * unzip * ignore * moreram * 14k * ref * deployment * 12k * uselocal * go * dockercomd * reorder * iamgename * installs * tart * cli * clideps * y * dockerce * nodock * multi * rmecr * dev
45 lines
960 B
Go
45 lines
960 B
Go
package document_test
|
|
|
|
import (
|
|
"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) {
|
|
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)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, doc, adoc)
|
|
}
|