Multiple methods write to os.Stdout instead of v.Stdout, breaking testability #26
Odkázat v novém úkolu
Zablokovat Uživatele
Smazat větev „%!s()“
Smazání větve je trvalé. Přestože zrušená větev může existovat i po krátkou dobu, než bude skutečně odstraněna, NELZE ji většinou vrátit. Pokračovat?
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, ...).