Skip to content

Commit

Permalink
fix(httploader): error handling for no such host
Browse files Browse the repository at this point in the history
  • Loading branch information
cshum committed Oct 18, 2022
1 parent 3bf4015 commit 0023ee9
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions imagor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ func TestNewBlobFromPathNotFound(t *testing.T) {
w := httptest.NewRecorder()
app.ServeHTTP(w, r)
assert.Equal(t, 404, w.Code)
e := ErrNotFound
e.Data = "foobar"
assert.Equal(t, jsonStr(e), w.Body.String())
assert.Equal(t, jsonStr(ErrNotFound), w.Body.String())

app = New(
WithDebug(true),
Expand Down Expand Up @@ -618,9 +616,7 @@ func TestWithLoadersStoragesProcessors(t *testing.T) {
http.MethodGet, "https://example.com/unsafe/empty", nil))
time.Sleep(time.Millisecond * 10)
assert.Equal(t, 404, w.Code)
e := ErrNotFound
e.Data = "empty"
assert.Equal(t, jsonStr(e), w.Body.String())
assert.Equal(t, jsonStr(ErrNotFound), w.Body.String())
assert.Nil(t, store.Map["empty"])
})
t.Run(fmt.Sprintf("not found on pass %d", i), func(t *testing.T) {
Expand All @@ -629,9 +625,7 @@ func TestWithLoadersStoragesProcessors(t *testing.T) {
http.MethodGet, "https://example.com/unsafe/boooo", nil))
time.Sleep(time.Millisecond * 10)
assert.Equal(t, 404, w.Code)
e := ErrNotFound
e.Data = "boooo"
assert.Equal(t, jsonStr(e), w.Body.String())
assert.Equal(t, jsonStr(ErrNotFound), w.Body.String())
})
t.Run(fmt.Sprintf("unexpected error %d", i), func(t *testing.T) {
w := httptest.NewRecorder()
Expand Down

0 comments on commit 0023ee9

Please sign in to comment.