From 0a5bdb5b7884884b353668b9915fab8fc38f0cd5 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Mon, 6 May 2024 16:45:45 -0400 Subject: [PATCH] test: add NoVerbose function on PackerCommand By default PackerCommands are run with PACKER_LOG=1. If for any reason we don't want that, we can remove it from the environment so we only see the user-facing logs. --- test/commands_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/commands_test.go b/test/commands_test.go index 24561f21e..0f54384be 100644 --- a/test/commands_test.go +++ b/test/commands_test.go @@ -33,6 +33,15 @@ func (ts *PackerTestSuite) PackerCommand() *packerCommand { } } +// NoVerbose removes the `PACKER_LOG=1` environment variable from the command +func (pc *packerCommand) NoVerbose() *packerCommand { + _, ok := pc.env["PACKER_LOG"] + if ok { + delete(pc.env, "PACKER_LOG") + } + return pc +} + // UsePluginDir sets the plugin directory in the environment to `dir` func (pc *packerCommand) UsePluginDir(dir string) *packerCommand { return pc.AddEnv("PACKER_PLUGIN_PATH", dir)