-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: init unittest script and run the first test case
PR-URL: #10 Reviewed-BY: hyj1991 <yeekwanvong@gmail.com>
- Loading branch information
Showing
9 changed files
with
139 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,55 @@ | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
# name: Node.js CI | ||
|
||
# on: | ||
# push: | ||
# branches: [ master ] | ||
# pull_request: | ||
# branches: [ master ] | ||
|
||
# jobs: | ||
# build: | ||
|
||
# runs-on: ${{ matrix.os }} | ||
|
||
# strategy: | ||
# matrix: | ||
# node-version: [8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x] | ||
# os: [ubuntu-latest, windows-latest, macos-latest] | ||
|
||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - name: Use Node.js ${{ matrix.node-version }} | ||
# uses: actions/setup-node@v1 | ||
# with: | ||
# node-version: ${{ matrix.node-version }} | ||
# - run: npm i -g npminstall && npminstall | ||
# - run: npm run ci | ||
# env: | ||
# CI: true | ||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
schedule: | ||
- cron: '0 2 * * *' | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [10, 12, 14] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
# https://github.com/marketplace/actions/setup-mysql | ||
- name: Setup MySQL | ||
uses: mirromutth/mysql-action@v1.1 | ||
with: | ||
mysql version: '5.7' | ||
mysql root password: 'root' | ||
|
||
# https://github.com/marketplace/actions/redis-server-in-github-actions | ||
- name: Redis Server in GitHub Actions | ||
uses: supercharge/redis-github-action@1.1.0 | ||
with: | ||
redis-version: 5 | ||
|
||
- name: Checkout Git Source | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install Dependencies | ||
run: npm i -g npminstall && npminstall | ||
|
||
- name: Continuous Integration | ||
run: npm run ci | ||
|
||
- name: Code Coverage | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
'use strict'; | ||
|
||
module.exports = () => { | ||
const config = {}; | ||
|
||
const password = process.env.MYSQL_ROOT_PASSWORD || 'root'; | ||
|
||
config.mysql = { | ||
app: true, | ||
agent: false, | ||
clients: { | ||
xprofiler_console: { | ||
host: '127.0.0.1', | ||
port: 3306, | ||
user: 'root', | ||
password, | ||
database: 'xprofiler_console_unittest', | ||
}, | ||
xprofiler_logs: { | ||
host: '127.0.0.1', | ||
port: 3306, | ||
user: 'root', | ||
password, | ||
database: 'xprofiler_logs_unittest', | ||
}, | ||
}, | ||
}; | ||
|
||
config.redis = { | ||
client: { | ||
sentinels: null, | ||
port: 6379, | ||
host: '127.0.0.1', | ||
password: '', | ||
db: 0, | ||
}, | ||
}; | ||
|
||
config.xprofilerConsole = 'http://127.0.0.1:8443'; | ||
|
||
config.xtransitManager = 'http://127.0.0.1:8543'; | ||
|
||
return config; | ||
}; |
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,10 @@ | ||
|
||
# init unit test database script | ||
|
||
PASSWORD=${MYSQL_ROOT_PASSWORD:-root} | ||
|
||
mysql -uroot -p${PASSWORD} -h127.0.0.1 -e 'DROP DATABASE IF EXISTS `xprofiler_console_unittest`; CREATE DATABASE `xprofiler_console_unittest`;' | ||
mysql -uroot -p${PASSWORD} -h127.0.0.1 -D 'xprofiler_console_unittest' < ${PWD}/db/init.sql | ||
mysql -uroot -p${PASSWORD} -h127.0.0.1 -D 'xprofiler_console_unittest' -e 'SHOW tables;' | ||
|
||
mysql -uroot -p${PASSWORD} -h127.0.0.1 -e 'DROP DATABASE IF EXISTS `xprofiler_logs_unittest`; CREATE DATABASE `xprofiler_logs_unittest`;' |
15 changes: 15 additions & 0 deletions
15
lib/plugin/egg-xprofiler-auth/app/extend/application.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,15 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
async mockUser(user) { | ||
this.mockContext({ | ||
user: { | ||
userId: 1, | ||
name: 'mockuser', | ||
nick: 'mocknick', | ||
mail: 'mockuser@mock.com', | ||
...user, | ||
}, | ||
}); | ||
}, | ||
}; |
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
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
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