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) }