Skip to content

Commit

Permalink
Merge pull request pulumi#355 from pulumi/stack72/fix-panic-on-empty-…
Browse files Browse the repository at this point in the history
…api-response

Prevent panic when response from server is nil
  • Loading branch information
stack72 committed Jul 31, 2019
2 parents 72959d0 + bcc2420 commit 52dccd4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions misc/test/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ func assertHTTPResultWithRetry(t *testing.T, output interface{}, headers map[str
if !assert.True(t, ok, fmt.Sprintf("expected `%s` output", output)) {
return false
}

if !(strings.HasPrefix(hostname, "https://") || strings.HasPrefix(hostname, "https://")) {
hostname = fmt.Sprintf("https://%s", hostname)
}
Expand Down Expand Up @@ -816,6 +817,11 @@ func assertHTTPResultWithRetry(t *testing.T, output interface{}, headers map[str
if !assert.NoError(t, err) {
return false
}

if !assert.NotNil(t, resp, "resp was nil") && !assert.NotNil(t, resp.Body, "resp.body was nil") {
return false
}

// Read the body
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
Expand Down

0 comments on commit 52dccd4

Please sign in to comment.