Multiple methods write to os.Stdout instead of v.Stdout, breaking testability #26
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/vaultik#26
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
Several methods in the
vaultikpackage write directly toos.Stdoutinstead of using the injectablev.Stdoutwriter. This breaks theTestVaultiktesting infrastructure which captures output via buffers.Affected methods:
ListSnapshots- usestabwriter.NewWriter(os.Stdout, ...)andjson.NewEncoder(os.Stdout)PurgeSnapshots- usesfmt.Println,fmt.Printf,fmt.ScanlnVerifySnapshotWithOptions- usesfmt.PrintfdirectlyoutputPruneBlobsJSON- package-level function usesos.StdoutoutputRemoveJSON- usesjson.NewEncoder(os.Stdout)ShowInfo- usesfmt.PrintfthroughoutImpact
v.Stdout, others bypass itFix
Replace all
os.Stdoutreferences withv.Stdoutandfmt.Printf/fmt.Printlnwithfmt.Fprintf(v.Stdout, ...).