Files
query-orchestration/test/docInitRunner/docinitrunner_test.go
T
Michael McGuinness 7001ca854c Merged in feature/docinitialisation (pull request #41)
Queuing Changes and Cfg Testing

* staarting

* staarting

* startedpush

* note

* save

* mocking

* removederrs

* fixtests

* cleanuperrs

* newenvsetup

* preppingtests

* queue

* mmovetocfgpassunittests

* sortoutconfig

* passinginteg

* deps

* fixtests
2025-02-03 17:30:50 +00:00

92 lines
2.2 KiB
Go

package integration_test
import (
"context"
"os"
"path"
documentinit "queryorchestration/internal/document/init"
"queryorchestration/internal/server/queue"
"queryorchestration/internal/test"
queryservice "queryorchestration/pkg/queryService"
"testing"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
"github.com/stretchr/testify/assert"
)
func TestDocInitRunner(t *testing.T) {
ctx := context.Background()
cfg := test.CreateBaseConfig()
cfg.BasePath = path.Join(os.Getenv("PWD"), "../..")
network, ncleanup := test.CreateNetwork(t, ctx)
defer ncleanup()
qcleanup := test.CreateQueueClient(t, ctx, &test.CreateQueueConfig{
Cfg: cfg,
Network: network,
})
defer qcleanup()
doccleanurl := test.CreateQueue(t, ctx, cfg, "docclean")
net, cleanup := test.CreateRunnersAndServicesNetwork(t, ctx, &test.EcosystemNetworkConfig{
Cfg: cfg,
Network: network,
Runners: []*test.RunnerNetworkConfig{
{
Name: test.DocInitRunner,
Env: map[string]string{
"DOCUMENT_CLEAN_URL": doccleanurl,
},
},
},
Services: []*test.ServiceNetworkConfig{
{
Name: test.QueryService,
},
},
})
defer cleanup()
qService, err := queryservice.NewClientWithResponses(net.Services[test.QueryService].URI)
assert.NoError(t, err)
clientRes, err := qService.CreateClientWithResponse(ctx, queryservice.ClientCreate{
Name: "example_name",
})
assert.NoError(t, err)
jobRes, err := qService.CreateJobWithResponse(ctx, queryservice.JobCreate{
ClientId: clientRes.JSON201.Id,
})
assert.NoError(t, err)
canSync := true
_, err = qService.UpdateClientWithResponse(ctx, clientRes.JSON201.Id, queryservice.ClientUpdate{
CanSync: &canSync,
})
assert.NoError(t, err)
_, err = qService.UpdateJobWithResponse(ctx, jobRes.JSON201.Id, queryservice.JobUpdate{
CanSync: &canSync,
})
assert.NoError(t, err)
document := documentinit.Create{
JobID: jobRes.JSON201.Id,
Location: "/I/am/here", // TODO
}
qcfg := &queue.Config{
URL: net.Runners[test.DocInitRunner].URI,
Client: cfg.QueueClient,
}
err = queue.Send(ctx, qcfg, document, map[string]types.MessageAttributeValue{})
assert.NoError(t, err)
_ = test.AssertMessageWait(t, ctx, &queue.Config{
URL: doccleanurl,
Client: cfg.GetQueueClient(),
}, []string{})
}