Add source bundle validation and inspection
This commit is contained in:
40
internal/app/inspect_test.go
Normal file
40
internal/app/inspect_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInspectPrintsBundleSummary(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
err := Inspect(context.Background(), InspectOptions{
|
||||
Path: filepath.Join("..", "bundle", "testdata", "valid_bundle"),
|
||||
Stdout: &stdout,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Inspect() error = %v", err)
|
||||
}
|
||||
output := stdout.String()
|
||||
for _, want := range []string{
|
||||
"Bundles: 1",
|
||||
"path=.",
|
||||
"id=weather.daily.brentwood.2026-05-30",
|
||||
"created=2026-05-30T11:10:00Z",
|
||||
"report.md size=16",
|
||||
"summary.txt size=8",
|
||||
} {
|
||||
if !strings.Contains(output, want) {
|
||||
t.Fatalf("Inspect() output = %q, want substring %q", output, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInspectRequiresPath(t *testing.T) {
|
||||
err := Inspect(context.Background(), InspectOptions{})
|
||||
if err == nil || !strings.Contains(err.Error(), "requires a path") {
|
||||
t.Fatalf("Inspect() error = %v, want required path", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user