Skip to content

Commit

Permalink
cmd/server: files: test validating an invalid file
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Aug 19, 2019
1 parent 90c0fb2 commit c0ba118
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/server/files_test.go
Expand Up @@ -296,9 +296,18 @@ func TestFiles__validateFile(t *testing.T) {
t.Errorf("unexpected body: %v", w.Body.String())
}

// error case
repo.err = errors.New("bad error")
// make the file invalid
repo.file.Header = imagecashletter.NewFileHeader()
w = httptest.NewRecorder()
router.ServeHTTP(w, req)
w.Flush()

if w.Code != http.StatusBadRequest {
t.Errorf("bogus HTTP status: %d: %v", w.Code, w.Body.String())
}

// repository error case
repo.err = errors.New("bad error")
w = httptest.NewRecorder()
router.ServeHTTP(w, req)
w.Flush()
Expand Down

0 comments on commit c0ba118

Please sign in to comment.