0815cb35fb
Basic Lint Checks * basic
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 TestListByJobId(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)
|
|
|
|
jobId := uuid.New()
|
|
doc := []*document.DocumentInList{
|
|
{
|
|
ID: uuid.New(),
|
|
Bucket: "bucketone",
|
|
Key: "keyone",
|
|
},
|
|
}
|
|
|
|
pool.ExpectQuery("name: ListDocumentsByJobId :many").WithArgs(database.MustToDBUUID(jobId)).
|
|
WillReturnRows(
|
|
pgxmock.NewRows([]string{"id", "bucket", "key"}).
|
|
AddRow(database.MustToDBUUID(doc[0].ID), doc[0].Bucket, doc[0].Key),
|
|
)
|
|
|
|
adoc, err := svc.ListByJobId(ctx, jobId)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, doc, adoc)
|
|
}
|