2025-01-24 14:52:56 +00:00
|
|
|
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()
|
|
|
|
|
|
2025-02-03 17:30:50 +00:00
|
|
|
c, cleanup := test.CreateServiceNetwork(t, ctx, &test.ServiceNetworkConfig{
|
|
|
|
|
Name: test.QueryService,
|
|
|
|
|
})
|
2025-01-24 14:52:56 +00:00
|
|
|
defer cleanup()
|
|
|
|
|
|
2025-02-03 17:30:50 +00:00
|
|
|
client, err := queryservice.NewClientWithResponses(c.URI)
|
|
|
|
|
assert.NoError(t, err)
|
2025-01-24 14:52:56 +00:00
|
|
|
|
|
|
|
|
clientRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{
|
|
|
|
|
Name: "example_name",
|
|
|
|
|
})
|
2025-02-03 17:30:50 +00:00
|
|
|
assert.NoError(t, err)
|
2025-01-24 14:52:56 +00:00
|
|
|
idRes, err := client.CreateJobWithResponse(ctx, queryservice.JobCreate{
|
|
|
|
|
ClientId: clientRes.JSON201.Id,
|
|
|
|
|
})
|
2025-02-03 17:30:50 +00:00
|
|
|
assert.NoError(t, err)
|
2025-01-24 14:52:56 +00:00
|
|
|
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)
|
2025-02-03 17:30:50 +00:00
|
|
|
assert.NoError(t, err)
|
2025-01-24 14:52:56 +00:00
|
|
|
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,
|
|
|
|
|
})
|
2025-02-03 17:30:50 +00:00
|
|
|
assert.NoError(t, err)
|
2025-01-24 14:52:56 +00:00
|
|
|
assert.NotNil(t, updateRes)
|
|
|
|
|
|
|
|
|
|
jobRes, err = client.GetJobWithResponse(ctx, id)
|
2025-02-03 17:30:50 +00:00
|
|
|
assert.NoError(t, err)
|
2025-01-24 14:52:56 +00:00
|
|
|
assert.Equal(t, id, jobRes.JSON200.Id)
|
|
|
|
|
assert.Equal(t, clientRes.JSON201.Id, jobRes.JSON200.ClientId)
|
|
|
|
|
assert.False(t, jobRes.JSON200.CanSync)
|
|
|
|
|
}
|