Skip to content

Commit

Permalink
test: fix test case fail on Node.js 20 (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Jan 4, 2024
1 parent 9f469ec commit 52832dd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 46 deletions.
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

0 comments on commit 52832dd

Please sign in to comment.