Skip to content

Commit

Permalink
[TECH] Eviter de contacter la BDD dans les tests unitaires via lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Sep 29, 2023
2 parents dc0550b + 6642a2c commit 1cbfbd3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ module.exports = {
],
},
],
'import/no-restricted-paths': ['error', { zones: [{ target: 'lib/domain/usecases', from: 'lib/infrastructure/repositories', except: [], message : "Repositories are automatically injected in use-case, you don't need to import them. Check for further details: https://github.com/1024pix/pix/blob/dev/docs/adr/0046-injecter-les-dependances-api.md" }] }],
'import/no-restricted-paths': ['error', { zones: [{ target: 'lib/domain/usecases', from: 'lib/infrastructure/repositories', except: [], message : "Repositories are automatically injected in use-case, you don't need to import them. Check for further details: https://github.com/1024pix/pix/blob/dev/docs/adr/0046-injecter-les-dependances-api.md" },{ "target": "tests/unit", "from": "db" }] }],
},
};
10 changes: 10 additions & 0 deletions api/tests/unit/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";

module.exports = {
extends: "../.eslintrc.cjs",
rules: {
"no-restricted-imports": ["error", {
paths: ["knex", "pg"]
}]
}
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, sinon, hFake } from '../../../test-helper.js';
// eslint-disable-next-line import/no-restricted-paths
import { knex } from '../../../../db/knex-database-connection.js';
import { redisMonitor } from '../../../../lib/infrastructure/utils/redis-monitor.js';
import { healthcheckController } from '../../../../lib/application/healthcheck/healthcheck-controller.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from '../../../test-helper.js';
// eslint-disable-next-line import/no-restricted-paths
import { databaseBuffer } from '../../../../db/database-builder/database-buffer.js';

describe('Unit | Tooling | DatabaseBuilder | database-buffer', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, sinon, catchErr } from '../../../test-helper.js';
// eslint-disable-next-line import/no-restricted-paths
import { DatabaseBuilder } from '../../../../db/database-builder/database-builder.js';

describe('Unit | Tooling | DatabaseBuilder | database-builder', function () {
Expand Down

0 comments on commit 1cbfbd3

Please sign in to comment.