Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added a test for 404 handling #7

Merged
merged 1 commit into from

2 participants

@naholyr

This PR is based on the previous one, which automatically ends the response when an error occurs: this one simply adds corresponding test.

@mikeal mikeal merged commit e1bfe58 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 30, 2011
  1. @naholyr

    Added a test for 404 handling

    naholyr authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 0 deletions.
  1. +12 −0 test/test.js
View
12 test/test.js
@@ -136,6 +136,12 @@ function testhttp () {
x.pipe(resp)
})
+ s.on('/test-not-found', function (req, resp) {
+ var x = filed(__dirname + "/there-is-no-such-file-here.no-extension")
+ req.pipe(x)
+ x.pipe(resp)
+ })
+
s.listen(port, function () {
fs.createReadStream(testfile).pipe(request.put(url+'/test-req'))
@@ -189,6 +195,12 @@ function testhttp () {
console.log("Passed GET of directory index, full pipe")
})
+ request.get(url+'/test-not-found', function (e, resp, body) {
+ if (e) throw e
+ if (resp.statusCode !== 404) throw new Error('Status code is not 404 it is '+resp.statusCode)
+ console.log("Passed Not Found produces 404")
+ })
+
})
}
Something went wrong with that request. Please try again.