From 0abedd88775ff6f9cf9514a827cda53d6d5286f3 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 19 Sep 2017 11:31:18 -0700 Subject: [PATCH] e2e: allow tests to set environment variables for command runs --- e2e/e2e.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e/e2e.go b/e2e/e2e.go index dbc457e1c..b8c1d69ea 100644 --- a/e2e/e2e.go +++ b/e2e/e2e.go @@ -17,6 +17,7 @@ import ( type binary struct { binPath string workDir string + env []string } // NewBinary prepares a temporary directory containing the files from the @@ -93,6 +94,12 @@ func NewBinary(binaryPath, workingDir string) *binary { } } +// AddEnv appends an entry to the environment variable table passed to any +// commands subsequently run. +func (b *binary) AddEnv(entry string) { + b.env = append(b.env, entry) +} + // Cmd returns an exec.Cmd pre-configured to run the generated Terraform // binary with the given arguments in the temporary working directory. // @@ -108,6 +115,8 @@ func (b *binary) Cmd(args ...string) *exec.Cmd { // end-to-end testing of our Checkpoint interactions.) cmd.Env = append(cmd.Env, "CHECKPOINT_DISABLE=1") + cmd.Env = append(cmd.Env, b.env...) + return cmd }