Merged in feature/docresult (pull request #105)

Document Result Endpoint

* testing

* cleantesting

* progress

* query

* lint

* readme

* dockerclient

* api

* passtest

* tests

* test
This commit is contained in:
Michael McGuinness
2025-03-17 18:14:15 +00:00
parent f7c41c4ef3
commit 555b6d420b
105 changed files with 3276 additions and 2484 deletions
+104
View File
@@ -0,0 +1,104 @@
package endtoend_test
import (
"context"
"os"
"path"
"regexp"
"testing"
"queryorchestration/internal/serviceconfig"
"queryorchestration/internal/serviceconfig/queue"
"queryorchestration/internal/test"
queryapi "queryorchestration/pkg/queryAPI"
"github.com/oapi-codegen/runtime/types"
"github.com/stretchr/testify/assert"
)
type QueryConfig struct {
serviceconfig.BaseConfig
queue.QueueConfig
}
func TestQueryAPI(t *testing.T) {
ctx := context.Background()
cfg := &QueryConfig{}
test.SetCfgProvider(t, cfg)
cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../.."))
network, ncleanup := test.CreateNetwork(t, ctx)
defer ncleanup()
_, clean := test.CreateAWSContainer(t, ctx, &test.CreateAWSConfig{
Cfg: cfg,
Network: network,
})
defer clean()
err := cfg.SetQueueClient(ctx)
assert.NoError(t, err)
queryversionsyncurl := test.CreateQueue(t, ctx, cfg, test.QueryVersionSyncRunnerName)
c, cleanup := test.CreateAPINetwork(t, ctx, &test.ServiceNetworkConfig{
Cfg: cfg,
Network: network,
API: test.QueryAPI,
})
defer cleanup()
client, err := queryapi.NewClientWithResponses(c.URI)
assert.NoError(t, err)
idRes, err := client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{
Type: queryapi.CONTEXTFULL,
})
assert.NoError(t, err)
assert.NotNil(t, idRes)
assert.NotNil(t, idRes.JSON201)
contextID := idRes.JSON201.Id
assert.NotEmpty(t, contextID)
jcfg := "{}"
idRes, err = client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{
Type: queryapi.JSONEXTRACTOR,
Config: &jcfg,
})
assert.NoError(t, err)
jsonID := idRes.JSON201.Id
queryRes, err := client.GetQueryWithResponse(ctx, jsonID)
assert.NoError(t, err)
assert.Equal(t, jsonID, queryRes.JSON200.Id)
assert.Equal(t, queryapi.JSONEXTRACTOR, queryRes.JSON200.Type)
assert.Equal(t, int32(1), queryRes.JSON200.ActiveVersion)
assert.Equal(t, int32(1), queryRes.JSON200.LatestVersion)
assert.Equal(t, jcfg, *queryRes.JSON200.Config)
assert.Nil(t, queryRes.JSON200.RequiredQueries)
queriesRes, err := client.ListQueriesWithResponse(ctx)
assert.NoError(t, err)
assert.Len(t, queriesRes.JSON200.Queries, 2)
aV := int32(2)
res, err := client.UpdateQueryWithResponse(ctx, jsonID, queryapi.QueryUpdate{
ActiveVersion: &aV,
RequiredQueries: &[]types.UUID{
contextID,
},
})
assert.NoError(t, err)
assert.NotNil(t, res)
test.AssertMessageBody(t, ctx, cfg, queryversionsyncurl, regexp.MustCompile(`{"id":".+"}`))
queryRes, err = client.GetQueryWithResponse(ctx, jsonID)
assert.NoError(t, err)
assert.Equal(t, jsonID, queryRes.JSON200.Id)
assert.Equal(t, queryapi.JSONEXTRACTOR, queryRes.JSON200.Type)
assert.Equal(t, int32(2), queryRes.JSON200.ActiveVersion)
assert.Equal(t, int32(2), queryRes.JSON200.LatestVersion)
assert.Equal(t, jcfg, *queryRes.JSON200.Config)
assert.ElementsMatch(t, []types.UUID{contextID}, *queryRes.JSON200.RequiredQueries)
}