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

test: fix test case fail on Node.js 20 #89

Merged
merged 1 commit into from
Jan 4, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ on:
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '27 12 * * 1'

jobs:
analyze:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ on:
pull_request:
branches: [ master ]

workflow_dispatch: {}

jobs:
Job:
name: Node.js
uses: artusjs/github-actions/.github/workflows/node-test.yml@v1
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest, windows-latest'
version: '14, 16, 18, 20'
6 changes: 1 addition & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ on:
push:
branches: [ master ]

workflow_dispatch: {}

jobs:
release:
name: Node.js
uses: artusjs/github-actions/.github/workflows/node-release.yml@v1
uses: eggjs/github-actions/.github/workflows/node-release.yml@master
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
checkTest: false
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = app => {
return class Home extends app.Controller {
* index() {
async index() {
this.ctx.body = 'hello csrfToken cookieOptions signed';
}
};
Expand Down
42 changes: 7 additions & 35 deletions test/method_not_allow.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const methods = require('methods');
const mm = require('egg-mock');

describe('test/method_not_allow.test.js', () => {
Expand All @@ -17,40 +16,13 @@ describe('test/method_not_allow.test.js', () => {

after(() => app.close());

it('should allow', done => {
let count = 0,
exCount = 0,
keepgoing = true;
const exclude = [ 'trace', 'track' ];

const ms = methods.filter(m => {
return app[m];
});

ms.forEach(method => {
if (!keepgoing) {
return;
}
if (exclude.indexOf(method) !== -1) {
++exCount;
return;
}

app.httpRequest()[method]('/')
.expect(200)
.end(err => {
if (err) {
keepgoing = false;
return done(err);
}

++count;

if (count === ms.length - exCount) {
return done();
}
});
});
it('should allow', async () => {
const methods = [ 'get', 'post', 'head', 'put', 'delete' ];
for (const method of methods) {
console.log(method);
await app.httpRequest()[method]('/')
.expect(200);
}
});

it('should not allow trace method', () => {
Expand Down