Files
query-orchestration/test/queryService/jobcollectorservice_test.go
T
Michael McGuinness 4ccb980593 Merged in feature/jobcollector (pull request #30)
Initial Job Collector (changes pending)

* movearroundtocleancollector

* internalgetfunctions

* completecollectorquery

* simplify

* fixtests

* addvendor

* noplaceholder
2025-01-21 12:28:46 +00:00

70 lines
1.6 KiB
Go

package integration_test
import (
"context"
"queryorchestration/internal/test"
queryservice "queryorchestration/pkg/queryService"
"testing"
"github.com/google/uuid"
"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: &[]string{
contextRes.JSON201.Id,
},
})
assert.Nil(t, err)
jobID := uuid.NewString()
fields := []queryservice.JobCollectorField{
{
Name: "json_output",
QueryId: jsonRes.JSON201.Id,
},
}
collRes, err := client.GetJobCollectorByJobIdWithResponse(ctx, jobID)
assert.Nil(t, err)
assert.NotNil(t, collRes.JSON200)
assert.EqualExportedValues(t, queryservice.JobCollector{
JobId: jobID,
Fields: fields,
}, *collRes.JSON200)
fields = []queryservice.JobCollectorField{
{
Name: "json",
QueryId: jsonRes.JSON201.Id,
},
}
res, err := client.UpdateJobCollectorByJobIdWithResponse(ctx, jobID, queryservice.JobCollectorUpdate{
Fields: &fields,
})
assert.Nil(t, err)
assert.EqualExportedValues(t, queryservice.JobCollector{
JobId: jobID,
Fields: fields,
}, *collRes.JSON200)
assert.NotNil(t, res)
}