Files
query-orchestration/api/docInitRunner/runner_test.go
T
jay brown a9d81a1094 remove parallel
remove parallel to stabilize ci/cd
2025-07-22 10:29:44 -07:00

61 lines
1.6 KiB
Go

package docinitrunner_test
import (
"regexp"
"testing"
"time"
docinitrunner "queryorchestration/api/docInitRunner"
"queryorchestration/internal/database/repository"
documentinit "queryorchestration/internal/document/init"
"queryorchestration/internal/server/runner"
"queryorchestration/internal/serviceconfig/objectstore"
"queryorchestration/internal/serviceconfig/queue"
"queryorchestration/internal/serviceconfig/queue/documentsync"
"queryorchestration/internal/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type DocInitConfig struct {
runner.BaseConfig[docinitrunner.Body]
documentsync.DocSyncConfig
queue.QueueConfig
objectstore.ObjectStoreConfig
}
func TestDocInitRunner(t *testing.T) {
cfg := &DocInitConfig{}
test.CreateDB(t, cfg)
acfg := test.CreateAWSContainer(t, cfg)
test.SetQueueClient(t, t.Context(), cfg, acfg.ExternalEndpoint)
cfg.DocumentSyncURL = test.CreateQueue(t, cfg, test.DocSyncRunnerName)
runner := docinitrunner.New(&docinitrunner.Services{
Document: documentinit.New(cfg),
})
err := cfg.GetDBQueries().CreateClient(t.Context(), &repository.CreateClientParams{
Clientid: "clientid",
Name: "client_name",
})
require.NoError(t, err)
location := objectstore.BucketKey{
Location: objectstore.Import,
ClientID: "clientid",
CreatedAt: time.Now().UTC(),
}
doc := docinitrunner.Body{
Bucket: "bucket",
Key: location.String(),
Hash: "hash",
}
assert.True(t, runner.Process(t.Context(), doc))
test.AssertMessageBody(t, cfg, cfg.GetDocumentSyncURL(), regexp.MustCompile(`{"id":".+"}`))
}