Unify inspection configuration handling
This commit is contained in:
@@ -1183,6 +1183,24 @@ output:
|
||||
}
|
||||
}
|
||||
|
||||
func TestInspectionParsersPreserveExplicitEmptyConfigPath(t *testing.T) {
|
||||
promptConfig, err := parsePromptInspectionArgs([]string{"--config=", "--prompt", "fixture"})
|
||||
if err != nil {
|
||||
t.Fatalf("parse prompt inspection: %v", err)
|
||||
}
|
||||
if promptConfig.configPath != "" || !promptConfig.configExplicit {
|
||||
t.Fatalf("expected explicit empty prompt config path, got %+v", promptConfig)
|
||||
}
|
||||
|
||||
profileConfig, err := parseProfileInspectionArgs([]string{"--config=", "--profile", "fixture"})
|
||||
if err != nil {
|
||||
t.Fatalf("parse profile inspection: %v", err)
|
||||
}
|
||||
if profileConfig.configPath != "" || !profileConfig.configExplicit {
|
||||
t.Fatalf("expected explicit empty profile config path, got %+v", profileConfig)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPromptkitV09DefinitionsRenderThroughCLI(t *testing.T) {
|
||||
fixtureRoot := promptkitV09FixtureRoot(t)
|
||||
configPath := writePromptkitV09Config(t, fixtureRoot, true)
|
||||
@@ -1283,27 +1301,22 @@ func TestPromptkitV09ProfileInspectionResolvesSupportedTargets(t *testing.T) {
|
||||
t.Setenv("FIXTURE_PROFILE_API_KEY", secret)
|
||||
|
||||
fixtureRoot := promptkitV09FixtureRoot(t)
|
||||
configPath := writePromptkitV09Config(t, fixtureRoot, false)
|
||||
profileDir := filepath.Join(fixtureRoot, "profiles")
|
||||
configPath := writePromptkitV09Config(t, fixtureRoot, true)
|
||||
tests := []struct {
|
||||
name string
|
||||
profileID string
|
||||
profileDir string
|
||||
wantBackend string
|
||||
wantModel string
|
||||
wantAPIKeyEnv string
|
||||
}{
|
||||
{name: "inherited custom backend", profileID: "custom-derived", profileDir: profileDir, wantBackend: "fixture-custom", wantModel: "fixture-derived-model", wantAPIKeyEnv: "FIXTURE_PROFILE_API_KEY"},
|
||||
{name: "endpoint only", profileID: "endpoint-only", profileDir: profileDir, wantModel: "fixture-endpoint-model"},
|
||||
{name: "inherited custom backend", profileID: "custom-derived", wantBackend: "fixture-custom", wantModel: "fixture-derived-model", wantAPIKeyEnv: "FIXTURE_PROFILE_API_KEY"},
|
||||
{name: "endpoint only", profileID: "endpoint-only", wantModel: "fixture-endpoint-model"},
|
||||
{name: "built in", profileID: "deepseek-4-flash", wantBackend: "openrouter", wantModel: "deepseek/deepseek-v4-flash", wantAPIKeyEnv: "OPENROUTER_API_KEY"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
args := []string{"profile", "--config", configPath, "--profile", tc.profileID, "--format", "json"}
|
||||
if tc.profileDir != "" {
|
||||
args = append(args, "--profile-dir", tc.profileDir)
|
||||
}
|
||||
code, stdout, stderr := runCLICommand(t, inspectCommand, args)
|
||||
if code != ExitOK {
|
||||
t.Fatalf("expected ExitOK, got %d stderr=%q", code, stderr)
|
||||
@@ -1326,11 +1339,22 @@ func TestPromptkitV09ProfileInspectionResolvesSupportedTargets(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
configWithoutPromptDir := writePromptkitV09Config(t, fixtureRoot, false)
|
||||
code, _, stderr := runCLICommand(t, inspectCommand, []string{
|
||||
"profile",
|
||||
"--config", configWithoutPromptDir,
|
||||
"--profile-dir", filepath.Join(fixtureRoot, "profiles"),
|
||||
"--profile", "custom-derived",
|
||||
})
|
||||
if code != ExitOK {
|
||||
t.Fatalf("profile inspection unexpectedly required a prompt directory: %q", stderr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProfileInspectionHonorsDirectoryPrecedenceOutputAndFailures(t *testing.T) {
|
||||
fixtureRoot := promptkitV09FixtureRoot(t)
|
||||
configPath := writePromptkitV09Config(t, fixtureRoot, false)
|
||||
configPath := writePromptkitV09Config(t, fixtureRoot, true)
|
||||
overrideDir := t.TempDir()
|
||||
writeProfileFile(t, overrideDir, "custom-derived", "http://127.0.0.1:9000/v1", "override-model")
|
||||
outPath := filepath.Join(t.TempDir(), "inspection.json")
|
||||
|
||||
Reference in New Issue
Block a user