Skip to content

Commit

Permalink
with output matching
Browse files Browse the repository at this point in the history
  • Loading branch information
csquared committed Nov 21, 2015
1 parent 09d8630 commit ca006ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
12 changes: 7 additions & 5 deletions cmd/convox/start_test.go
Expand Up @@ -26,6 +26,7 @@ func TestStartWithMissingEnv(t *testing.T) {
temp, _ := ioutil.TempDir("", "convox-test")
appDir := temp + "/app"
os.Mkdir(appDir, 0777)
defer os.RemoveAll(appDir)

d1 := []byte(manifestRequired)
ioutil.WriteFile(appDir+"/docker-compose.yml", d1, 0777)
Expand All @@ -45,17 +46,18 @@ func TestStartWithNoEnvOk(t *testing.T) {
temp, _ := ioutil.TempDir("", "convox-test")
appDir := temp + "/app"
os.Mkdir(appDir, 0777)
defer os.RemoveAll(appDir)

fmt.Println(appDir)
d1 := []byte(manifestExplicitEqual)
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: 0,
Command: fmt.Sprintf("convox start"),
Dir: appDir,
Env: map[string]string{"CONVOX_CONFIG": temp},
OutMatch: "docker run",
Exit: 0,
},
)
}
21 changes: 13 additions & 8 deletions test/exec.go
Expand Up @@ -13,13 +13,14 @@ import (
)

type ExecRun struct {
Command string
Env map[string]string
Exit int
Dir string
Stdin string
Stdout string
Stderr string
Command string
Env map[string]string
Exit int
Dir string
Stdin string
Stdout string
OutMatch string
Stderr string
}

func (er ExecRun) Test(t *testing.T) {
Expand All @@ -30,9 +31,13 @@ func (er ExecRun) Test(t *testing.T) {
if er.Stdout != "" {
assert.Equal(t, er.Stdout, stdout, "stdout should be equal")
}
if er.OutMatch != "" {
assert.Contains(t, stdout, er.OutMatch,
fmt.Sprintf("stdout %q should contain %q", stdout, er.OutMatch))
}
if er.Stderr != "" {
assert.Contains(t, stderr, er.Stderr,
fmt.Sprintf("stderr should contain %q", stderr))
fmt.Sprintf("stderr %q should contain %q", stderr, er.Stderr))
}
}

Expand Down

0 comments on commit ca006ad

Please sign in to comment.