Isolate pipeline configuration discovery

This commit is contained in:
2026-09-16 04:26:24 +00:00
parent 869e68e834
commit df213bc2ba
8 changed files with 137 additions and 19 deletions

View File

@@ -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
}