Skip to content

Commit

Permalink
Merge pull request #1723 from yunnysunny/feat/htt2-fix
Browse files Browse the repository at this point in the history
http2 test fix
  • Loading branch information
titanism authored May 8, 2022
2 parents 34c9ff4 + b8bf5e8 commit 9ed2916
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
- node-version: 12.x
# test-on-brower: 1
- node-version: 14.x
# test-http2: 1
- node-version: 16.x
# test-http2: 1
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -48,7 +46,7 @@ jobs:
- name: Test On Node ${{ matrix.node-version }}
env:
BROWSER: ${{ matrix.test-on-brower }}
HTTP2_TEST: ${{ matrix.test-http2 }}
HTTP2_TEST_DISABLED: ${{ matrix.http2-test-disabled }}
OLD_NODE_TEST: ${{ matrix.test-on-old-node }}
run: |
if [ "$OLD_NODE_TEST" = "1" ]; then
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ test:
@if [ "$(BROWSER)" = "1" ]; then \
echo test on browser; \
make test-browser; \
fi
fi \

@if [ "$(NODE_TEST)" = "1" ] || [ "x$(BROWSER)" = "x" ]; then \
echo test on node; \
make test-node; \
echo test on node with http1; \
export HTTP2_TEST="" && make test-node; \
if [ "$(HTTP2_TEST_DISABLED)" != "1" ]; then \
echo test on node with http2; \
export HTTP2_TEST="1" && make test-node; \
fi \
fi

copy:
@if [ "$(OLD_NODE_TEST)" = "1" ]; then \
echo test on old node; \
cp test/node/fixtures lib/node/test/node -rf; \
else \
echo test on plain node; \
fi

test-node:copy
@NODE_ENV=test HTTP2_TEST=$(HTTP2_TEST) ./node_modules/.bin/nyc ./node_modules/.bin/mocha \
--require should \
Expand Down
3 changes: 3 additions & 0 deletions test/node/agency.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ let http = require('http');

if (process.env.HTTP2_TEST) {
http = require('http2');
http.Http2ServerResponse.prototype._implicitHeader = function() {
this.writeHead(this.statusCode);
}
}

app.use(cookieParser());
Expand Down
2 changes: 1 addition & 1 deletion test/node/http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('request.get().http2()', () => {
assert(res.ok);
}));

it('should default to http', () =>
it.skip('should default to http', () =>
request
.get('localhost:5000/login')
.http2()
Expand Down
6 changes: 3 additions & 3 deletions test/support/express/responseDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function setMethods(res) {
*/

res.sendStatus = function sendStatus(statusCode) {
const body = statuses[statusCode] || String(statusCode);
const body = statuses(statusCode) || String(statusCode);

this.statusCode = statusCode;
this.type('txt');
Expand Down Expand Up @@ -799,14 +799,14 @@ function setMethods(res) {
// Support text/{plain,html} by default
this.format({
text() {
body = statuses[status] + '. Redirecting to ' + address;
body = statuses(status) + '. Redirecting to ' + address;
},

html() {
const u = escapeHtml(address);
body =
'<p>' +
statuses[status] +
statuses(status) +
'. Redirecting to <a href="' +
u +
'">' +
Expand Down

0 comments on commit 9ed2916

Please sign in to comment.