Isolate pipeline configuration discovery
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
configkit "gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
)
|
||||
|
||||
// restoreEnvAfterTest clears names for a test and restores both their prior
|
||||
@@ -47,3 +49,29 @@ func mustWriteSecretFile(t *testing.T, path, value string) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func commandDependenciesForPipelineCandidates(candidates ...string) commandDependencies {
|
||||
ownedCandidates := append([]string(nil), candidates...)
|
||||
return commandDependencies{resolvePipelineConfigPath: func(flagValue string) (string, error) {
|
||||
return resolvePipelineConfigPathWithCandidates(flagValue, ownedCandidates)
|
||||
}}
|
||||
}
|
||||
|
||||
func guardedMissingPipelineDiscovery(t *testing.T) (commandDependencies, string, pipelineExecutor) {
|
||||
t.Helper()
|
||||
candidate := filepath.Join(t.TempDir(), "missing-pipeline.yml")
|
||||
deps := commandDependenciesForPipelineCandidates(candidate)
|
||||
deps.loadSecretsDir = func(string) (*configkit.SecretsReport, error) {
|
||||
t.Fatal("secret bootstrap continued after pipeline discovery failed")
|
||||
return nil, nil
|
||||
}
|
||||
deps.loadPipelineConfig = func(string, config.PipelineLoadOptions) (*config.PipelineConfig, error) {
|
||||
t.Fatal("typed pipeline loading continued after pipeline discovery failed")
|
||||
return nil, nil
|
||||
}
|
||||
executor := func(context.Context, *config.Config, BoundedPlan, RunOptions) (*RunSummary, error) {
|
||||
t.Fatal("pipeline execution continued after pipeline discovery failed")
|
||||
return nil, nil
|
||||
}
|
||||
return deps, candidate, executor
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user