From 171cdbbf939e12153d93a1c06806a7ad507ced3c Mon Sep 17 00:00:00 2001 From: Chris Arcand Date: Wed, 22 Sep 2021 15:55:56 -0500 Subject: [PATCH] command: Clean up testInputResponseMap before failing on unused answers If you don't, the unused answers will persist in the package-level var and bleed in to other tests. --- internal/command/command_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/command/command_test.go b/internal/command/command_test.go index d1a43cf659..929bfb4397 100644 --- a/internal/command/command_test.go +++ b/internal/command/command_test.go @@ -716,12 +716,15 @@ func testInputMap(t *testing.T, answers map[string]string) func() { // Return the cleanup return func() { - if len(testInputResponseMap) > 0 { - t.Fatalf("expected no unused answers provided to command.testInputMap, got: %v", testInputResponseMap) - } + var unusedAnswers = testInputResponseMap + // First, clean up! test = true testInputResponseMap = nil + + if len(unusedAnswers) > 0 { + t.Fatalf("expected no unused answers provided to command.testInputMap, got: %v", unusedAnswers) + } } }