Files
query-orchestration/internal/test/api.go
T
Michael McGuinness fee71e7740 Merged in feature/postprocessing (pull request #114)
Feature/postprocessing

* tests

* passtest

* fixshorttests

* mosttests

* improvingbasedockerfile

* testspeeds

* testing

* host

* canparallel

* clean

* passfullsuite

* singlepagemax

* test

* findfeatures

* findstables

* tbls

* tablestoo

* tablestoo

* lateraltests

* tableloc

* cleanup

* inlinetable

* childids

* cleanup

* tests
2025-04-22 14:40:16 +00:00

67 lines
1.4 KiB
Go

package test
import (
"context"
"fmt"
"testing"
queryapi "queryorchestration/api/queryAPI"
"queryorchestration/internal/serviceconfig"
"github.com/docker/go-connections/nat"
"github.com/stretchr/testify/require"
)
type APIName string
const (
QueryAPIName APIName = queryapi.Name
)
type API struct {
Name APIName
DownstreamQueues []RunnerName
}
type APIConfig struct {
API API
MockHTTP string
}
func CreateAPI(t testing.TB, ctx context.Context, cfg serviceconfig.ConfigProvider, network string, config *APIConfig) (*Container, func()) {
port, err := nat.NewPort("tcp", "8080")
require.NoError(t, err)
container, cleanup := createContainer(t, ctx, network, &containerConfig{
Cfg: cfg,
Name: string(config.API.Name),
DownstreamQueues: config.API.DownstreamQueues,
MockHTTP: config.MockHTTP,
WaitForMsg: "⇨ http server started on [::]:8080",
})
host, err := container.Host(ctx)
require.NoError(t, err)
mappedPort, err := container.MappedPort(ctx, port)
require.NoError(t, err)
address := fmt.Sprintf("http://%s:%s", host, mappedPort.Port())
return &Container{
URI: address,
Container: container,
}, cleanup
}
var QueryAPI = API{
Name: QueryAPIName,
DownstreamQueues: []RunnerName{
ClientSyncRunnerName,
QueryVersionSyncRunnerName,
},
}
var apis = []API{
QueryAPI,
}