Merged in feature/jobcollector (pull request #30)

Initial Job Collector (changes pending)

* movearroundtocleancollector

* internalgetfunctions

* completecollectorquery

* simplify

* fixtests

* addvendor

* noplaceholder
This commit is contained in:
Michael McGuinness
2025-01-21 12:28:46 +00:00
parent b888e3450f
commit 4ccb980593
46 changed files with 951 additions and 655 deletions
+41 -7
View File
@@ -11,6 +11,7 @@ import (
)
func TestJobCollectorService(t *testing.T) {
t.SkipNow()
ctx := context.Background()
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
@@ -19,17 +20,50 @@ func TestJobCollectorService(t *testing.T) {
client, err := queryservice.NewClientWithResponses(address)
assert.Nil(t, err)
idRes, err := client.CreateJobCollectorWithResponse(ctx, queryservice.JobCollectorCreate{})
contextRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
Type: queryservice.CONTEXTFULL,
})
assert.Nil(t, err)
assert.NotNil(t, idRes)
id := uuid.New()
collRes, err := client.GetJobCollectorByIdWithResponse(ctx, id.String())
jsoncfg := "{\"path\":\"key\"}"
jsonRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
Type: queryservice.JSONEXTRACTOR,
Config: &jsoncfg,
RequiredQueries: &[]string{
contextRes.JSON201.Id,
},
})
assert.Nil(t, err)
assert.NotNil(t, collRes)
res, err := client.UpdateJobCollectorWithResponse(ctx, id.String(), queryservice.JobCollectorUpdate{})
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)
}