version, info, remote info, config, and database delete wrote plain text straight to stdout, so they were unstyled and ignored --quiet. Output is now governed by internal/ui in two buckets. Status lines and confirmations (config init, config set, the database delete prompt) go through the ui message methods and are silenced by --quiet. The data a command exists to produce is written plain -- the version/info/remote-info reports, the snapshot list table, config get values, and the --json documents -- and is never suppressed, since a script depends on it and a marker would corrupt a table or document. The database delete confirmation prompt is always shown. Pure-cli commands reach ui through a small commandUI helper. Model: opus-4-8
31 lines
787 B
Go
31 lines
787 B
Go
package vaultik_test
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"sneak.berlin/go/vaultik/internal/ui"
|
|
"sneak.berlin/go/vaultik/internal/vaultik"
|
|
)
|
|
|
|
// TestShowInfo_QuietSuppressesReport checks that --quiet silences the
|
|
// whole info report. The report is human-facing status, not a scriptable
|
|
// value, so under --quiet the command produces nothing (and touches none
|
|
// of its dependencies, which is why this minimal instance suffices).
|
|
func TestShowInfo_QuietSuppressesReport(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var out bytes.Buffer
|
|
|
|
v := &vaultik.Vaultik{
|
|
Stdout: &out,
|
|
UI: ui.NewWithColor(&out, false),
|
|
}
|
|
v.UI.SetQuiet(true)
|
|
|
|
require.NoError(t, v.ShowInfo())
|
|
require.Empty(t, out.String(),
|
|
"the info report must be suppressed under --quiet")
|
|
}
|