Merged in feature/splittests (pull request #140)

Split Tests

* split
This commit is contained in:
Michael McGuinness
2025-05-12 20:54:16 +00:00
parent f5061f53db
commit 9dfd867906
6 changed files with 614 additions and 215 deletions
+35 -14
View File
@@ -113,7 +113,12 @@ type Dependencies struct {
Network string
}
func CreateFullDependencies(t testing.TB, ctx context.Context, cfg FullDependenciesConfig) Dependencies {
type FullDependenciesParams struct {
NoObjectStore bool
Runners *[]RunnerName
}
func CreateFullDependenciesWithParams(t testing.TB, cfg FullDependenciesConfig, params *FullDependenciesParams) Dependencies {
network := GetNetwork(t)
deps := Dependencies{
@@ -127,29 +132,37 @@ func CreateFullDependencies(t testing.TB, ctx context.Context, cfg FullDependenc
go func() {
deps.AWSConfig = CreateAWSContainer(t, cfg, network)
SetQueueClient(t, ctx, cfg, deps.AWSConfig.ExternalEndpoint)
SetQueueClient(t, t.Context(), cfg, deps.AWSConfig.ExternalEndpoint)
var lock sync.Mutex
for _, runner := range runners {
runs := params.Runners
if runs == nil {
allRuns := []RunnerName{}
for _, run := range runners {
allRuns = append(allRuns, run.Name)
}
runs = &allRuns
}
for _, runner := range *runs {
wg.Add(1)
go func() {
queue := CreateQueue(t, ctx, cfg, runner.Name)
queue := CreateQueue(t, t.Context(), cfg, runner)
lock.Lock()
deps.QueueURLs[runner.Name] = queue
deps.QueueURLs[runner] = queue
lock.Unlock()
wg.Done()
}()
}
SetStoreClient(t, ctx, cfg, deps.AWSConfig.ExternalEndpoint)
CreateBucket(t, ctx, cfg)
SetBucketNotifs(t, ctx, cfg)
if !params.NoObjectStore {
SetStoreClient(t, t.Context(), cfg, deps.AWSConfig.ExternalEndpoint)
CreateBucket(t, t.Context(), cfg)
SetBucketNotifs(t, t.Context(), cfg)
}
wg.Done()
}()
@@ -166,15 +179,19 @@ func CreateFullDependencies(t testing.TB, ctx context.Context, cfg FullDependenc
return deps
}
func CreateFullDependencies(t testing.TB, ctx context.Context, cfg FullDependenciesConfig) Dependencies {
return CreateFullDependenciesWithParams(t, cfg, &FullDependenciesParams{})
}
type APINetwork struct {
Dependencies Dependencies
API *Container
}
func CreateAPINetwork(t testing.TB, ctx context.Context, cfg FullDependenciesConfig, api API) (*APINetwork, func()) {
deps := CreateFullDependencies(t, ctx, cfg)
func CreateAPINetworkWithParams(t testing.TB, cfg FullDependenciesConfig, api API, params *FullDependenciesParams) (*APINetwork, func()) {
deps := CreateFullDependenciesWithParams(t, cfg, params)
c, ccleanup := CreateAPI(t, ctx, cfg, deps.Network, &APIConfig{
c, ccleanup := CreateAPI(t, t.Context(), cfg, deps.Network, &APIConfig{
API: api,
MockHTTP: string(deps.MockServer.Internal),
})
@@ -185,6 +202,10 @@ func CreateAPINetwork(t testing.TB, ctx context.Context, cfg FullDependenciesCon
}, ccleanup
}
func CreateAPINetwork(t testing.TB, ctx context.Context, cfg FullDependenciesConfig, api API) (*APINetwork, func()) {
return CreateAPINetworkWithParams(t, cfg, api, &FullDependenciesParams{})
}
func GetAlias(t testing.TB, baseName string) string {
name := fmt.Sprintf("%s_%s", baseName, t.Name())
name = strings.ToLower(name)