test: restore previous log writer in dependency warning tests

Save and restore the prior log.Writer() instead of hardcoding os.Stderr so the global logger output is not clobbered for other tests.

Signed-off-by: Arnav Nagzirkar <113314200+arnavnagzirkar@users.noreply.github.com>
pull/32197/head
Arnav Nagzirkar 1 month ago
parent c86f77b806
commit 7204d80e71

@ -615,8 +615,9 @@ func TestProcessDependencyEnabledNoSpuriousWarnings(t *testing.T) {
// Capture standard log output to detect spurious warnings from CoalesceValues.
var buf bytes.Buffer
oldOutput := log.Writer()
log.SetOutput(&buf)
defer log.SetOutput(os.Stderr)
defer log.SetOutput(oldOutput)
if err := processDependencyEnabled(parent, parent.Values, ""); err != nil {
t.Fatalf("unexpected error: %v", err)

@ -615,8 +615,9 @@ func TestProcessDependencyEnabledNoSpuriousWarnings(t *testing.T) {
// Capture standard log output to detect spurious warnings from CoalesceValues.
var buf bytes.Buffer
oldOutput := log.Writer()
log.SetOutput(&buf)
defer log.SetOutput(os.Stderr)
defer log.SetOutput(oldOutput)
if err := processDependencyEnabled(parent, parent.Values, ""); err != nil {
t.Fatalf("unexpected error: %v", err)

Loading…
Cancel
Save