package endtoend import ( "context" "queryorchestration/internal/test" queryservice "queryorchestration/pkg/queryService" "testing" "github.com/stretchr/testify/assert" ) func TestJob(t *testing.T) { ctx := context.Background() c, cleanup := test.CreateServiceNetwork(t, ctx, &test.ServiceNetworkConfig{ Name: test.QueryService, Env: map[string]string{ "JOB_SYNC_URL": "/i/am/here", "QUERY_VERSION_SYNC_URL": "iamthere", }, }) defer cleanup() client, err := queryservice.NewClientWithResponses(c.URI) assert.NoError(t, err) clientRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{ Name: "example_name", }) assert.NoError(t, err) idRes, err := client.CreateJobWithResponse(ctx, queryservice.JobCreate{ ClientId: clientRes.JSON201.Id, }) assert.NoError(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.NoError(t, err) assert.Equal(t, id, jobRes.JSON200.Id) assert.Equal(t, clientRes.JSON201.Id, jobRes.JSON200.ClientId) assert.False(t, jobRes.JSON200.CanSync) assert.Equal(t, queryservice.INSYNC, jobRes.JSON200.Status) updateCanSync := !jobRes.JSON200.CanSync updateRes, err := client.UpdateJobWithResponse(ctx, id, queryservice.JobUpdate{ CanSync: &updateCanSync, }) assert.NoError(t, err) assert.NotNil(t, updateRes) jobRes, err = client.GetJobWithResponse(ctx, id) assert.NoError(t, err) assert.Equal(t, id, jobRes.JSON200.Id) assert.Equal(t, clientRes.JSON201.Id, jobRes.JSON200.ClientId) assert.False(t, jobRes.JSON200.CanSync) assert.Equal(t, queryservice.INSYNC, jobRes.JSON200.Status) }