Simplify inspect command handling
This commit is contained in:
@@ -581,6 +581,45 @@ func TestRunInspectMissingMetadata(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunInspectRunCommandsParseRunIDAndConfig(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
configPath := filepath.Join(tempDir, "config.yml")
|
||||
configBody := "workspace:\n root: " + filepath.Join(tempDir, "workspace") + "\n"
|
||||
if err := os.WriteFile(configPath, []byte(configBody), 0o600); err != nil {
|
||||
t.Fatalf("write config: %v", err)
|
||||
}
|
||||
runner := Runner{Clock: fixedClock()}
|
||||
commands := []string{"metadata", "briefing", "data-package", "prior", "sources"}
|
||||
|
||||
for _, command := range commands {
|
||||
t.Run(command+" requires run id", func(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
err := runner.Run(context.Background(), []string{"inspect", command, "--config", configPath}, &stdout, &stderr)
|
||||
if err == nil {
|
||||
t.Fatal("Run() error = nil, want missing run id error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "requires a run id") {
|
||||
t.Fatalf("error = %q, want missing run id context", err.Error())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run(command+" accepts config", func(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
err := runner.Run(context.Background(), []string{"inspect", command, "--config", configPath, "missing"}, &stdout, &stderr)
|
||||
if err == nil {
|
||||
t.Fatal("Run() error = nil, want missing metadata error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "metadata for run id") {
|
||||
t.Fatalf("error = %q, want missing metadata context", err.Error())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveGenerateCommands(t *testing.T) {
|
||||
runner := Runner{Clock: fixedClock()}
|
||||
tests := []struct {
|
||||
|
||||
Reference in New Issue
Block a user