-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add new test case for runInAnonymousContextScope (eggjs#5141)
Since 'runInAnoymousContextScope' now has a new feature with a request as a parameter, it lacks a new test case, this is the test case for it. Refs: eggjs#5134
- Loading branch information
Showing
6 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/fixtures/apps/app-runInAnonymousContextScope-withRequest/app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module.exports = class Boot { | ||
constructor(app) { | ||
this.app = app; | ||
} | ||
|
||
async beforeClose() { | ||
|
||
const request = { | ||
headers: { | ||
host: '127.0.0.2', | ||
'x-forwarded-for': '127.0.0.2', | ||
}, | ||
querystring: 'Testing', | ||
host: '127.0.0.2', | ||
hostname: '127.0.0.2', | ||
protocol: 'http', | ||
secure: 'false', | ||
method: 'GET', | ||
url: '/', | ||
path: '/', | ||
socket: { | ||
remoteAddress: '127.0.0.2', | ||
remotePort: 7001, | ||
}, | ||
}; | ||
|
||
await this.app.runInAnonymousContextScope(async ctx => { | ||
ctx.logger.info('inside before close on ctx logger'); | ||
this.app.logger.info('inside before close on app logger'); | ||
}, request); | ||
this.app.logger.info('outside before close on app logger'); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
test/fixtures/apps/app-runInAnonymousContextScope-withRequest/config/config.default.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.keys = 'foo'; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/apps/app-runInAnonymousContextScope-withRequest/config/config.unittest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exports.logger = { | ||
consoleLevel: 'NONE', | ||
}; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/apps/app-runInAnonymousContextScope-withRequest/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "app-runInAnonymousContextScope-withRequest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters