Skip to content

Commit

Permalink
Merge pull request #53 from convox/build-error
Browse files Browse the repository at this point in the history
better errors during unexpected build scenario
  • Loading branch information
ddollar committed Sep 29, 2015
2 parents 6892365 + 7ef5752 commit bb26069
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/convox/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ func executeBuildDir(c *cli.Context, dir string, app string) (string, error) {
return "", err
}

if build.Id == "" {
return "", fmt.Errorf("unable to fetch build id")
}

err = rackClient(c).StreamBuildLogs(app, build.Id, os.Stdout)

if err != nil {
Expand All @@ -205,6 +209,10 @@ func executeBuildUrl(c *cli.Context, url string, app string) (string, error) {
return "", err
}

if build.Id == "" {
return "", fmt.Errorf("unable to fetch build id")
}

err = rackClient(c).StreamBuildLogs(app, build.Id, os.Stdout)

if err != nil {
Expand Down
43 changes: 43 additions & 0 deletions cmd/convox/builds_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"testing"

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

func TestBuildsPreventAgainstCreating(t *testing.T) {
ts := testServer(t,
test.Http{Method: "GET", Path: "/apps/foo", Code: 200, Response: client.App{Name: "foo", Status: "creating"}},
)

defer ts.Close()

test.Runs(t,
test.ExecRun{
Command: "convox build https://example.org --app foo",
Exit: 1,
Stdout: "",
Stderr: "ERROR: app is still creating: foo\n",
},
)
}

func TestBuildsCreateReturnsNoBuild(t *testing.T) {
ts := testServer(t,
test.Http{Method: "GET", Path: "/apps/foo", Code: 200, Response: client.App{Name: "foo", Status: "running"}},
test.Http{Method: "POST", Path: "/apps/foo/builds", Body: "repo=https%3A%2F%2Fexample.org", Code: 200, Response: client.Build{}},
)

defer ts.Close()

test.Runs(t,
test.ExecRun{
Command: "convox build https://example.org --app foo",
Exit: 1,
Stdout: "",
Stderr: "ERROR: unable to fetch build id\n",
},
)
}

0 comments on commit bb26069

Please sign in to comment.