Files
query-orchestration/test/queryService/job_test.go
T
Michael McGuinness 4ec1d51a12 Merged in feature/jobcrud (pull request #35)
Job CRUD + Collector Integration

* startedcreate

* openapispec

* createjobintegration

* jobgetcontroller

* jobcreateclient

* updatejob

* job

* collector
2025-01-24 14:52:56 +00:00

53 lines
1.4 KiB
Go

package integration_test
import (
"context"
"queryorchestration/internal/test"
queryservice "queryorchestration/pkg/queryService"
"testing"
"github.com/stretchr/testify/assert"
)
func TestJob(t *testing.T) {
ctx := context.Background()
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
defer cleanup()
client, err := queryservice.NewClientWithResponses(address)
assert.Nil(t, err)
clientRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{
Name: "example_name",
})
assert.Nil(t, err)
idRes, err := client.CreateJobWithResponse(ctx, queryservice.JobCreate{
ClientId: clientRes.JSON201.Id,
})
assert.Nil(t, err)
assert.NotNil(t, idRes)
assert.NotNil(t, idRes.JSON201)
assert.NotNil(t, idRes.JSON201.Id)
id := idRes.JSON201.Id
jobRes, err := client.GetJobWithResponse(ctx, id)
assert.Nil(t, err)
assert.Equal(t, id, jobRes.JSON200.Id)
assert.Equal(t, clientRes.JSON201.Id, jobRes.JSON200.ClientId)
assert.False(t, jobRes.JSON200.CanSync)
updateCanSync := !jobRes.JSON200.CanSync
updateRes, err := client.UpdateJobWithResponse(ctx, id, queryservice.JobUpdate{
CanSync: &updateCanSync,
})
assert.Nil(t, err)
assert.NotNil(t, updateRes)
jobRes, err = client.GetJobWithResponse(ctx, id)
assert.Nil(t, err)
assert.Equal(t, id, jobRes.JSON200.Id)
assert.Equal(t, clientRes.JSON201.Id, jobRes.JSON200.ClientId)
assert.False(t, jobRes.JSON200.CanSync)
}