4ec1d51a12
Job CRUD + Collector Integration * startedcreate * openapispec * createjobintegration * jobgetcontroller * jobcreateclient * updatejob * job * collector
86 lines
2.4 KiB
Go
86 lines
2.4 KiB
Go
package integration_test
|
|
|
|
import (
|
|
"context"
|
|
"queryorchestration/internal/test"
|
|
queryservice "queryorchestration/pkg/queryService"
|
|
"testing"
|
|
|
|
"github.com/oapi-codegen/runtime/types"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestJobCollectorService(t *testing.T) {
|
|
t.SkipNow()
|
|
ctx := context.Background()
|
|
|
|
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
|
defer cleanup()
|
|
|
|
client, err := queryservice.NewClientWithResponses(address)
|
|
assert.Nil(t, err)
|
|
|
|
contextRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
|
|
Type: queryservice.CONTEXTFULL,
|
|
})
|
|
assert.Nil(t, err)
|
|
|
|
jsoncfg := "{\"path\":\"key\"}"
|
|
jsonRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
|
|
Type: queryservice.JSONEXTRACTOR,
|
|
Config: &jsoncfg,
|
|
RequiredQueries: &[]types.UUID{
|
|
contextRes.JSON201.Id,
|
|
},
|
|
})
|
|
assert.Nil(t, err)
|
|
|
|
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",
|
|
QueryId: jsonRes.JSON201.Id,
|
|
},
|
|
}
|
|
|
|
collRes, err := client.GetJobCollectorByJobIdWithResponse(ctx, id)
|
|
assert.Nil(t, err)
|
|
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)
|
|
|
|
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.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)
|
|
}
|