Skip to content

Commit

Permalink
test for enforcing env
Browse files Browse the repository at this point in the history
  • Loading branch information
csquared committed Nov 21, 2015
1 parent ff1b0cb commit 370e227
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions cmd/convox/start_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

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

"github.com/convox/rack/test"
)

var manifestRequired string = `www:
environment:
- FOO
image: httpd
`

func TestStartWithMissingEnv(t *testing.T) {
temp, _ := ioutil.TempDir("", "convox-test")
appDir := temp + "/app"
os.Mkdir(appDir, 0777)

d1 := []byte(manifestRequired)
ioutil.WriteFile(appDir+"/docker-compose.yml", d1, 0777)

test.Runs(t,
test.ExecRun{
Command: fmt.Sprintf("convox start"),
Dir: appDir,
Env: map[string]string{"CONVOX_CONFIG": temp},
Exit: 1,
Stderr: "ERROR: env expected: FOO",
},
)
}
3 changes: 2 additions & 1 deletion test/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type ExecRun struct {
Command string
Env map[string]string
Exit int
Dir string
Stdin string
Stdout string
Stderr string
Expand All @@ -39,7 +40,7 @@ func (er ExecRun) exec() (string, string, int, error) {

cmd.Stdout = stdout
cmd.Stderr = stderr

cmd.Dir = er.Dir
cmd.Env = os.Environ()

for k, v := range er.Env {
Expand Down

0 comments on commit 370e227

Please sign in to comment.