Add source bundle validation and inspection
This commit is contained in:
@@ -21,7 +21,7 @@ func inspectCommand(ctx context.Context, args []string, stdout, stderr io.Writer
|
||||
if len(args) == 1 {
|
||||
path = args[0]
|
||||
}
|
||||
if err := app.Inspect(ctx, app.InspectOptions{Path: path}); err != nil {
|
||||
if err := app.Inspect(ctx, app.InspectOptions{Path: path, Stdout: stdout}); err != nil {
|
||||
return fail(stderr, err)
|
||||
}
|
||||
return exitOK
|
||||
@@ -31,6 +31,6 @@ func printInspectHelp(w io.Writer) {
|
||||
fmt.Fprint(w, `Usage:
|
||||
distributor inspect <path>
|
||||
|
||||
The inspect command is present but bundle inspection is not implemented yet.
|
||||
Print a normalized summary of local source bundles.
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ func TestExecuteVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlaceholderCommandsFailClearly(t *testing.T) {
|
||||
tests := []string{"run", "validate", "inspect"}
|
||||
func TestRunWithoutDryRunFailsClearly(t *testing.T) {
|
||||
tests := []string{"run"}
|
||||
|
||||
for _, command := range tests {
|
||||
t.Run(command, func(t *testing.T) {
|
||||
@@ -63,6 +63,32 @@ func TestPlaceholderCommandsFailClearly(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteValidate(t *testing.T) {
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
code := Execute(context.Background(), []string{"validate", filepath.Join("..", "bundle", "testdata", "valid_bundle")}, &stdout, &stderr)
|
||||
|
||||
if code != exitOK {
|
||||
t.Fatalf("exit code = %d, want %d; stderr = %q", code, exitOK, stderr.String())
|
||||
}
|
||||
if got, want := stdout.String(), "Validated 1 bundle(s)\n"; got != want {
|
||||
t.Fatalf("stdout = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteInspect(t *testing.T) {
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
code := Execute(context.Background(), []string{"inspect", filepath.Join("..", "bundle", "testdata", "valid_bundle")}, &stdout, &stderr)
|
||||
|
||||
if code != exitOK {
|
||||
t.Fatalf("exit code = %d, want %d; stderr = %q", code, exitOK, stderr.String())
|
||||
}
|
||||
if !strings.Contains(stdout.String(), "id=weather.daily.brentwood.2026-05-30") {
|
||||
t.Fatalf("stdout = %q, want bundle summary", stdout.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteRunDryRun(t *testing.T) {
|
||||
configPath := filepath.Join(t.TempDir(), "config.yml")
|
||||
err := os.WriteFile(configPath, []byte(`
|
||||
|
||||
@@ -21,7 +21,7 @@ func validateCommand(ctx context.Context, args []string, stdout, stderr io.Write
|
||||
if len(args) == 1 {
|
||||
path = args[0]
|
||||
}
|
||||
if err := app.Validate(ctx, app.ValidateOptions{Path: path}); err != nil {
|
||||
if err := app.Validate(ctx, app.ValidateOptions{Path: path, Stdout: stdout}); err != nil {
|
||||
return fail(stderr, err)
|
||||
}
|
||||
return exitOK
|
||||
@@ -31,6 +31,6 @@ func printValidateHelp(w io.Writer) {
|
||||
fmt.Fprint(w, `Usage:
|
||||
distributor validate <path>
|
||||
|
||||
The validate command is present but bundle validation is not implemented yet.
|
||||
Validate a local source bundle directory or a tree containing source bundles.
|
||||
`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user