Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing tests to pass on io.js #1426

Merged
merged 6 commits into from Mar 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions tests/test-headers.js
Expand Up @@ -93,12 +93,21 @@ tape('upper-case Host header and redirect', function(t) {
// Horrible hack to observe the raw data coming to the server (before Node
// core lower-cases the headers)
var rawData = ''

s.on('connection', function(socket) {
var ondata = socket.ondata
socket.ondata = function(d, start, end) {
rawData += d.slice(start, end).toString()
return ondata.apply(this, arguments)
if (socket.ondata) {
var ondata = socket.ondata
}
function handledata (d, start, end) {
if (ondata) {
rawData += d.slice(start, end).toString()
return ondata.apply(this, arguments)
} else {
rawData += d
}
}
socket.on('data', handledata)
socket.ondata = handledata
})

function checkHostHeader(host) {
Expand Down
2 changes: 1 addition & 1 deletion tests/test-localAddress.js
Expand Up @@ -9,7 +9,7 @@ tape('bind to invalid address', function(t) {
localAddress: '1.2.3.4'
}, function(err, res) {
t.notEqual(err, null)
t.equal(err.message, 'bind EADDRNOTAVAIL')
t.equal(true, /bind EADDRNOTAVAIL/.test(err.message))
t.equal(res, undefined)
t.end()
})
Expand Down
8 changes: 3 additions & 5 deletions tests/test-proxy-connect.js
Expand Up @@ -52,7 +52,7 @@ tape('proxy', function(t) {
t.equal(err, null)
t.equal(res.statusCode, 200)
t.equal(body, 'derp\n')
t.equal(data, [
var re = new RegExp([
'CONNECT google.com:80 HTTP/1.1',
'Proxy-Authorization: Basic dXNlcjpwYXNz',
'dont-send-to-dest: ok',
Expand All @@ -66,11 +66,9 @@ tape('proxy', function(t) {
'dont-send-to-proxy: ok',
'accept: yo',
'user-agent: just another foobar',
'host: google.com',
'Connection: keep-alive',
'',
''
'host: google.com'
].join('\r\n'))
t.equal(true, re.test(data))
t.equal(called, true, 'the request must be made to the proxy server')
t.end()
})
Expand Down