Multiple methods write to os.Stdout instead of v.Stdout, breaking testability #26

Open
opened 2026-02-08 21:01:08 +01:00 by clawbot · 0 comments
Collaborator

Bug

Several methods in the vaultik package write directly to os.Stdout instead of using the injectable v.Stdout writer. This breaks the TestVaultik testing infrastructure which captures output via buffers.

Affected methods:

  • ListSnapshots - uses tabwriter.NewWriter(os.Stdout, ...) and json.NewEncoder(os.Stdout)
  • PurgeSnapshots - uses fmt.Println, fmt.Printf, fmt.Scanln
  • VerifySnapshotWithOptions - uses fmt.Printf directly
  • outputPruneBlobsJSON - package-level function uses os.Stdout
  • outputRemoveJSON - uses json.NewEncoder(os.Stdout)
  • ShowInfo - uses fmt.Printf throughout

Impact

  • Output cannot be captured in tests
  • Output cannot be redirected programmatically
  • Inconsistent behavior: some methods use v.Stdout, others bypass it

Fix

Replace all os.Stdout references with v.Stdout and fmt.Printf/fmt.Println with fmt.Fprintf(v.Stdout, ...).

## Bug Several methods in the `vaultik` package write directly to `os.Stdout` instead of using the injectable `v.Stdout` writer. This breaks the `TestVaultik` testing infrastructure which captures output via buffers. Affected methods: - `ListSnapshots` - uses `tabwriter.NewWriter(os.Stdout, ...)` and `json.NewEncoder(os.Stdout)` - `PurgeSnapshots` - uses `fmt.Println`, `fmt.Printf`, `fmt.Scanln` - `VerifySnapshotWithOptions` - uses `fmt.Printf` directly - `outputPruneBlobsJSON` - package-level function uses `os.Stdout` - `outputRemoveJSON` - uses `json.NewEncoder(os.Stdout)` - `ShowInfo` - uses `fmt.Printf` throughout ## Impact - Output cannot be captured in tests - Output cannot be redirected programmatically - Inconsistent behavior: some methods use `v.Stdout`, others bypass it ## Fix Replace all `os.Stdout` references with `v.Stdout` and `fmt.Printf`/`fmt.Println` with `fmt.Fprintf(v.Stdout, ...)`.
clawbot self-assigned this 2026-02-08 21:01:08 +01:00
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/vaultik#26
No description provided.