package vaultik_test import ( "testing" "time" "github.com/stretchr/testify/require" "sneak.berlin/go/vaultik/internal/log" ) // TestListSnapshots_QuietSuppressesTableNotJSON is the --quiet contract // for `snapshot list`: the human table is silenced, but the --json // document a script depends on still emits. A local snapshot with its // remote counterpart present is used so there are no drift notes, whose // warnings would emit even under --quiet. func TestListSnapshots_QuietSuppressesTableNotJSON(t *testing.T) { log.Initialize(log.Config{}) t.Parallel() env := newListEnv(t) ts := time.Date(2026, 3, 1, 10, 0, 0, 0, time.UTC) env.addLocal(t, listLocalID, ts) env.addRemote(t, listLocalID, ts) env.v.UI.SetQuiet(true) // Table mode: nothing on stdout. require.NoError(t, env.v.ListSnapshots(false)) require.Empty(t, env.stdout.String(), "the table must be suppressed under --quiet") // JSON mode: the document is still written despite the quiet UI. env.stdout.Reset() require.NoError(t, env.v.ListSnapshots(true)) rows := decodeListJSON(t, env.stdout.String()) require.Len(t, rows, 1) require.Equal(t, listLocalID, rows[0].ID, "the --json document must still emit under --quiet") }