Merged in feature/jobcrud (pull request #35)
Job CRUD + Collector Integration * startedcreate * openapispec * createjobintegration * jobgetcontroller * jobcreateclient * updatejob * job * collector
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
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)
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
queryservice "queryorchestration/pkg/queryService"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/oapi-codegen/runtime/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -29,13 +29,22 @@ func TestJobCollectorService(t *testing.T) {
|
||||
jsonRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
|
||||
Type: queryservice.JSONEXTRACTOR,
|
||||
Config: &jsoncfg,
|
||||
RequiredQueries: &[]string{
|
||||
RequiredQueries: &[]types.UUID{
|
||||
contextRes.JSON201.Id,
|
||||
},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
jobID := uuid.NewString()
|
||||
clientRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{
|
||||
Name: "example_name",
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
jobRes, err := client.CreateJobWithResponse(ctx, queryservice.JobCreate{
|
||||
ClientId: clientRes.JSON201.Id,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
id := jobRes.JSON201.Id
|
||||
|
||||
fields := []queryservice.JobCollectorField{
|
||||
{
|
||||
Name: "json_output",
|
||||
@@ -43,27 +52,34 @@ func TestJobCollectorService(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
collRes, err := client.GetJobCollectorByJobIdWithResponse(ctx, jobID)
|
||||
collRes, err := client.GetJobCollectorByJobIdWithResponse(ctx, id)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, collRes.JSON200)
|
||||
assert.EqualExportedValues(t, queryservice.JobCollector{
|
||||
JobId: jobID,
|
||||
Fields: fields,
|
||||
}, *collRes.JSON200)
|
||||
assert.Equal(t, id, collRes.JSON200.JobId)
|
||||
assert.Equal(t, 1, collRes.JSON200.ActiveVersion)
|
||||
assert.Equal(t, 1, collRes.JSON200.LatestVersion)
|
||||
assert.Equal(t, 1, collRes.JSON200.MinimumCleanerVersion)
|
||||
assert.Equal(t, 1, collRes.JSON200.MinimumTextVersion)
|
||||
assert.Len(t, collRes.JSON200.Fields, 0)
|
||||
|
||||
fields = []queryservice.JobCollectorField{
|
||||
{
|
||||
Name: "json",
|
||||
QueryId: jsonRes.JSON201.Id,
|
||||
},
|
||||
}
|
||||
res, err := client.UpdateJobCollectorByJobIdWithResponse(ctx, jobID, queryservice.JobCollectorUpdate{
|
||||
Fields: &fields,
|
||||
av := int32(2)
|
||||
minClean := int32(2)
|
||||
minText := int32(2)
|
||||
uRes, err := client.UpdateJobCollectorByJobIdWithResponse(ctx, id, queryservice.JobCollectorUpdate{
|
||||
ActiveVersion: &av,
|
||||
MinimumCleanerVersion: &minClean,
|
||||
MinimumTextVersion: &minText,
|
||||
Fields: &fields,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, queryservice.JobCollector{
|
||||
JobId: jobID,
|
||||
Fields: fields,
|
||||
}, *collRes.JSON200)
|
||||
assert.NotNil(t, res)
|
||||
assert.Nil(t, uRes)
|
||||
|
||||
collRes, err = client.GetJobCollectorByJobIdWithResponse(ctx, id)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, id, collRes.JSON200.JobId)
|
||||
assert.Equal(t, 2, collRes.JSON200.ActiveVersion)
|
||||
assert.Equal(t, 2, collRes.JSON200.LatestVersion)
|
||||
assert.Equal(t, 2, collRes.JSON200.MinimumCleanerVersion)
|
||||
assert.Equal(t, 2, collRes.JSON200.MinimumTextVersion)
|
||||
assert.Len(t, collRes.JSON200.Fields, 1)
|
||||
assert.ElementsMatch(t, fields, collRes.JSON200.Fields)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
queryservice "queryorchestration/pkg/queryService"
|
||||
"testing"
|
||||
|
||||
"github.com/oapi-codegen/runtime/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -49,7 +50,7 @@ func TestQueryService(t *testing.T) {
|
||||
aV := int32(2)
|
||||
res, err := client.UpdateQueryWithResponse(ctx, jsonID, queryservice.QueryUpdate{
|
||||
ActiveVersion: &aV,
|
||||
RequiredQueries: &[]string{
|
||||
RequiredQueries: &[]types.UUID{
|
||||
contextID,
|
||||
},
|
||||
})
|
||||
@@ -63,5 +64,5 @@ func TestQueryService(t *testing.T) {
|
||||
assert.Equal(t, int32(2), queryRes.JSON200.ActiveVersion)
|
||||
assert.Equal(t, int32(2), queryRes.JSON200.LatestVersion)
|
||||
assert.Nil(t, queryRes.JSON200.Config)
|
||||
assert.ElementsMatch(t, []string{contextID}, *queryRes.JSON200.RequiredQueries)
|
||||
assert.ElementsMatch(t, []types.UUID{contextID}, *queryRes.JSON200.RequiredQueries)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestQueryServiceTest(t *testing.T) {
|
||||
docId := uuid.New()
|
||||
|
||||
testRes, err := client.TestQueryWithResponse(ctx, id, queryservice.QueryTestRequest{
|
||||
DocumentId: docId.String(),
|
||||
DocumentId: docId,
|
||||
QueryVersion: int32(1),
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
Reference in New Issue
Block a user