Skip to content

Commit

Permalink
Move defer to remove file up, so that it always gets removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ejholmes committed Sep 13, 2016
1 parent e6f4aba commit b55d8b4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/cli/env_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cli_test

import (
"testing"
"time"
"fmt"
"io/ioutil"
"os"
"fmt"
"testing"
"time"
)

func TestConfig(t *testing.T) {
Expand Down Expand Up @@ -118,19 +118,20 @@ func TestConfigConsistency(t *testing.T) {
}

func TestEnvConfig(t *testing.T) {
file, err := ioutil.TempFile(os.TempDir(), "acme-inc.env")
f, err := ioutil.TempFile(os.TempDir(), "acme-inc.env")
if err != nil {
t.Fatal(err)
}
defer os.Remove(f.Name())

content := []byte("FOO=bar\\nmoarbar\n")
file.Write(content)
f.Write(content)

run(t, []Command{
DeployCommand("latest", "v1"),
{
fmt.Sprintf("env-load %s -a acme-inc", file.Name()),
fmt.Sprintf("Updated env vars from %s and restarted acme-inc.", file.Name()),
fmt.Sprintf("env-load %s -a acme-inc", f.Name()),
fmt.Sprintf("Updated env vars from %s and restarted acme-inc.", f.Name()),
},
})
defer os.Remove(file.Name())
}

0 comments on commit b55d8b4

Please sign in to comment.