Skip to content

Commit

Permalink
separate integration tests for adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Apr 1, 2024
1 parent d1d1ee6 commit ce830fb
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 15 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
strategy:
matrix:
node-version: [18.x, 20.x]
adapter: ["NeDB", "MongoDB", "Knex-SQLite", "Knex", "Knex-Postgresql", "Knex-MySQL", "Knex-MySQL2", "Knex-MSSQL"]
fail-fast: false
steps:
- uses: actions/checkout@v3
Expand All @@ -40,11 +41,24 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test:unit
- name: Start containers for ${{ matrix.adapter }} adapter
run: docker-compose up mongo -d
if: ${{ matrix.adapter == 'MongoDB' }}
working-directory: ./test

- name: Start containers for ${{ matrix.adapter }} adapter
run: docker-compose up postgres -d
if: ${{ matrix.adapter == 'Knex-Postgresql' }}
working-directory: ./test

- name: Start containers
run: docker-compose up -d
- name: Start containers for ${{ matrix.adapter }} adapter
run: docker-compose up mysql -d
if: ${{ matrix.adapter == 'Knex-MySQL' || matrix.adapter == 'Knex-MySQL2' }}
working-directory: ./test

- name: Start containers for ${{ matrix.adapter }} adapter
run: docker-compose up mssql mssql-create-db -d
if: ${{ matrix.adapter == 'Knex-MSSQL' }}
working-directory: ./test

- name: Sleeping 30 secs
Expand All @@ -60,8 +74,10 @@ jobs:

- name: Run integration tests
run: npm run test:integration
timeout-minutes: 10
env:
GITHUB_ACTIONS_CI: true
ADAPTER: ${{ matrix.adapter }}

# - name: Run leak detection tests
# run: npm run test:leak
Expand All @@ -77,8 +93,8 @@ jobs:
run: docker-compose down -v
working-directory: ./test

- name: Upload code coverage
run: npm run coverall
if: success() && github.ref == 'refs/heads/master'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
# - name: Upload code coverage
# run: npm run coverall
# if: success() && github.ref == 'refs/heads/master'
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Unit Test

on:
push:
branches:
- '**'
paths-ignore:
- '.vscode/**'
- 'benchmark/**'
- 'docs/**'
- 'examples/**'
- '*.md'

pull_request:
branches:
- master
paths-ignore:
- '.vscode/**'
- 'benchmark/**'
- 'docs/**'
- 'examples/**'
- '*.md'

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test:unit
2 changes: 1 addition & 1 deletion src/adapters/mongodb.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* @moleculer/database
* Copyright (c) 2022 MoleculerJS (https://github.com/moleculerjs/database)
* Copyright (c) 2024 MoleculerJS (https://github.com/moleculerjs/database)
* MIT Licensed
*/

Expand Down
12 changes: 7 additions & 5 deletions test/integration/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ if (process.env.GITHUB_ACTIONS_CI) {
} else {
// Local development tests
Adapters = [
/*{
{
type: "NeDB"
} ,*/
{ type: "MongoDB", options: { dbName: "db_int_test" } } /*,
},
{ type: "MongoDB", options: { dbName: "db_int_test" } },
{
name: "Knex-SQLite",
type: "Knex",
Expand All @@ -137,7 +137,7 @@ if (process.env.GITHUB_ACTIONS_CI) {
}
}
}
}*/ /*,
},
{
name: "Knex-Postgresql",
type: "Knex",
Expand Down Expand Up @@ -212,12 +212,14 @@ if (process.env.GITHUB_ACTIONS_CI) {
}
}
}
}*/
}
];
}

describe("Integration tests", () => {
for (const adapter of Adapters) {
if (process.env.ADAPTER && adapter.name !== process.env.ADAPTER) continue;

const getAdapter = options => {
if (adapter.options) return _.defaultsDeep({}, { options }, adapter);

Expand Down

0 comments on commit ce830fb

Please sign in to comment.