diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b6bc319..946ffdc 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -39,4 +39,9 @@ jobs: - run: docker-compose up -d + # First run just the small database test to get the test database synced to the current schema + # in a clean way. For some reason, the `run-many` is necessary here. If this line simply uses + # nx test database, the connection to the DB gets cut off before the sync is complete. + - run: NX_CLOUD_DISTRIBUTED_EXECUTION=false npx nx run-many -t test --projects database + - run: NX_CLOUD_DISTRIBUTED_EXECUTION=false npx nx run-many -t test --coverage --passWithNoTests diff --git a/jest.config.ts b/jest.config.ts index 6b3f2d6..7d35575 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,5 +1,5 @@ -import { getJestProjectsAsync } from '@nx/jest'; +import { getJestProjectsAsync } from "@nx/jest"; export default async () => ({ - projects: await getJestProjectsAsync(), + projects: await getJestProjectsAsync() }); diff --git a/jest.preset.js b/jest.preset.js index ee18844..4d5b09c 100644 --- a/jest.preset.js +++ b/jest.preset.js @@ -1,4 +1,4 @@ -const nxPreset = require('@nx/jest/preset').default; +const nxPreset = require("@nx/jest/preset").default; module.exports = { ...nxPreset, @@ -8,9 +8,9 @@ module.exports = { branches: 85, functions: 95, lines: 95, - statements: 95, + statements: 95 } }, - setupFilesAfterEnv: ['./setup-jest.ts'], -} + setupFilesAfterEnv: ["./jest/setup-jest.ts"] +}; diff --git a/jest/setup-jest.ts b/jest/setup-jest.ts new file mode 100644 index 0000000..0c96228 --- /dev/null +++ b/jest/setup-jest.ts @@ -0,0 +1,26 @@ +import { Sequelize } from "sequelize-typescript"; +import { FactoryGirl, SequelizeAdapter } from "factory-girl-ts"; +import * as Entities from "@terramatch-microservices/database/entities"; + +let sequelize: Sequelize; + +beforeAll(async () => { + // To create this database, run the ./setup-test-database.sh script. + sequelize = new Sequelize({ + dialect: "mariadb", + host: "localhost", + port: 3360, + username: "wri", + password: "wri", + database: "terramatch_microservices_test", + models: Object.values(Entities), + logging: false + }); + + await sequelize.sync(); + FactoryGirl.setAdapter(new SequelizeAdapter()); +}); + +afterAll(async () => { + await sequelize.close(); +}); diff --git a/libs/common/src/lib/policies/user.policy.spec.ts b/libs/common/src/lib/policies/user.policy.spec.ts index 695c398..3ad4889 100644 --- a/libs/common/src/lib/policies/user.policy.spec.ts +++ b/libs/common/src/lib/policies/user.policy.spec.ts @@ -1,15 +1,16 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { PolicyService } from './policy.service'; -import { mockPermissions, mockUserId } from './policy.service.spec'; -import { User } from '@terramatch-microservices/database/entities'; -import { UnauthorizedException } from '@nestjs/common'; +import { Test, TestingModule } from "@nestjs/testing"; +import { PolicyService } from "./policy.service"; +import { mockPermissions, mockUserId } from "./policy.service.spec"; +import { User } from "@terramatch-microservices/database/entities"; +import { UnauthorizedException } from "@nestjs/common"; +import { UserFactory } from "@terramatch-microservices/database/factories"; -describe('UserPolicy', () => { +describe("UserPolicy", () => { let service: PolicyService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ - providers: [PolicyService], + providers: [PolicyService] }).compile(); service = module.get(PolicyService); @@ -19,21 +20,21 @@ describe('UserPolicy', () => { jest.restoreAllMocks(); }); - it('allows reading any user as admin', async () => { + it("allows reading any user as admin", async () => { mockUserId(123); - mockPermissions('users-manage'); - await expect(service.authorize('read', new User())).resolves.toBeUndefined(); - }) + mockPermissions("users-manage"); + await expect(service.authorize("read", new User())).resolves.toBeUndefined(); + }); - it('disallows reading other users as non-admin', async () => { + it("disallows reading other users as non-admin", async () => { mockUserId(123); mockPermissions(); - await expect(service.authorize('read', new User())).rejects.toThrow(UnauthorizedException); - }) + await expect(service.authorize("read", new User())).rejects.toThrow(UnauthorizedException); + }); - it('allows reading own user as non-admin', async () => { + it("allows reading own user as non-admin", async () => { mockUserId(123); mockPermissions(); - await expect(service.authorize('read', new User({ id: 123 }))).resolves.toBeUndefined(); - }) + await expect(service.authorize("read", await UserFactory.build({ id: 123 }))).resolves.toBeUndefined(); + }); }); diff --git a/libs/database/jest.config.ts b/libs/database/jest.config.ts index 6fef25b..76d3ee0 100644 --- a/libs/database/jest.config.ts +++ b/libs/database/jest.config.ts @@ -1,11 +1,19 @@ /* eslint-disable */ export default { - displayName: 'database', - preset: '../../jest.preset.js', - testEnvironment: 'node', + displayName: "database", + preset: "../../jest.preset.js", + testEnvironment: "node", transform: { - '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + "^.+\\.[tj]s$": ["ts-jest", { tsconfig: "/tsconfig.spec.json" }] }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/libs/database', + moduleFileExtensions: ["ts", "js", "html"], + coverageDirectory: "../../coverage/libs/database", + coverageThreshold: { + global: { + branches: 0, + functions: 0, + lines: 0, + statements: 0 + } + } }; diff --git a/libs/database/src/lib/database.module.spec.ts b/libs/database/src/lib/database.module.spec.ts new file mode 100644 index 0000000..adbbf99 --- /dev/null +++ b/libs/database/src/lib/database.module.spec.ts @@ -0,0 +1,9 @@ +import * as Entities from "./entities"; + +describe("DatabaseModule", () => { + it("Successfully syncs the database schema", async () => { + for (const Entity of Object.values(Entities)) { + await expect(Entity.sequelize?.getQueryInterface().tableExists(Entity.tableName)).resolves.toBe(true); + } + }); +}); diff --git a/libs/database/src/lib/entities/delayed-job.entity.ts b/libs/database/src/lib/entities/delayed-job.entity.ts index 147dd95..5ced0ad 100644 --- a/libs/database/src/lib/entities/delayed-job.entity.ts +++ b/libs/database/src/lib/entities/delayed-job.entity.ts @@ -1,17 +1,8 @@ -import { - AllowNull, - AutoIncrement, - Column, - Default, - Index, - Model, - PrimaryKey, - Table, -} from 'sequelize-typescript'; -import { BIGINT, INTEGER, JSON, STRING, UUID } from 'sequelize'; +import { AllowNull, AutoIncrement, Column, Default, Index, Model, PrimaryKey, Table } from "sequelize-typescript"; +import { BIGINT, INTEGER, JSON, STRING, UUID } from "sequelize"; -@Table({ tableName: 'delayed_jobs', underscored: true }) -export class DelayedJob extends Model { +@Table({ tableName: "delayed_jobs", underscored: true }) +export class DelayedJob extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) @@ -21,7 +12,7 @@ export class DelayedJob extends Model { @Column(UUID) uuid: string; - @Default('pending') + @Default("pending") @Column(STRING) status: string; diff --git a/libs/database/src/lib/entities/framework-user.entity.ts b/libs/database/src/lib/entities/framework-user.entity.ts index ab6d5de..3d47000 100644 --- a/libs/database/src/lib/entities/framework-user.entity.ts +++ b/libs/database/src/lib/entities/framework-user.entity.ts @@ -1,10 +1,10 @@ -import { AutoIncrement, Column, ForeignKey, Model, PrimaryKey, Table } from 'sequelize-typescript'; -import { BIGINT } from 'sequelize'; -import { Framework } from './framework.entity'; -import { User } from './user.entity'; +import { AutoIncrement, Column, ForeignKey, Model, PrimaryKey, Table } from "sequelize-typescript"; +import { BIGINT } from "sequelize"; +import { Framework } from "./framework.entity"; +import { User } from "./user.entity"; -@Table({ tableName: 'framework_user', underscored: true }) -export class FrameworkUser extends Model { +@Table({ tableName: "framework_user", underscored: true }) +export class FrameworkUser extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/framework.entity.ts b/libs/database/src/lib/entities/framework.entity.ts index 0c9f3fb..ad122ff 100644 --- a/libs/database/src/lib/entities/framework.entity.ts +++ b/libs/database/src/lib/entities/framework.entity.ts @@ -1,9 +1,9 @@ -import { AutoIncrement, Column, Model, PrimaryKey, Table } from 'sequelize-typescript'; -import { BIGINT, STRING } from 'sequelize'; +import { AutoIncrement, Column, Model, PrimaryKey, Table } from "sequelize-typescript"; +import { BIGINT, STRING } from "sequelize"; // A quick stub to get the information needed for users/me -@Table({ tableName: 'frameworks', underscored: true }) -export class Framework extends Model { +@Table({ tableName: "frameworks", underscored: true }) +export class Framework extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/indicator-output-field-monitoring.entity.ts b/libs/database/src/lib/entities/indicator-output-field-monitoring.entity.ts index 4f8f5ea..eab96f0 100644 --- a/libs/database/src/lib/entities/indicator-output-field-monitoring.entity.ts +++ b/libs/database/src/lib/entities/indicator-output-field-monitoring.entity.ts @@ -4,7 +4,7 @@ import { SitePolygon } from "./site-polygon.entity"; import { INDICATOR_SLUGS, IndicatorSlug } from "../constants"; @Table({ tableName: "indicator_output_field_monitoring", underscored: true, paranoid: true }) -export class IndicatorOutputFieldMonitoring extends Model { +export class IndicatorOutputFieldMonitoring extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/indicator-output-hectares.entity.ts b/libs/database/src/lib/entities/indicator-output-hectares.entity.ts index 076c2b0..c463fe5 100644 --- a/libs/database/src/lib/entities/indicator-output-hectares.entity.ts +++ b/libs/database/src/lib/entities/indicator-output-hectares.entity.ts @@ -4,7 +4,7 @@ import { SitePolygon } from "./site-polygon.entity"; import { INDICATOR_SLUGS, IndicatorSlug } from "../constants"; @Table({ tableName: "indicator_output_hectares", underscored: true, paranoid: true }) -export class IndicatorOutputHectares extends Model { +export class IndicatorOutputHectares extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/indicator-output-msu-carbon.entity.ts b/libs/database/src/lib/entities/indicator-output-msu-carbon.entity.ts index 052bc0d..8e7c001 100644 --- a/libs/database/src/lib/entities/indicator-output-msu-carbon.entity.ts +++ b/libs/database/src/lib/entities/indicator-output-msu-carbon.entity.ts @@ -4,7 +4,7 @@ import { SitePolygon } from "./site-polygon.entity"; import { INDICATOR_SLUGS, IndicatorSlug } from "../constants"; @Table({ tableName: "indicator_output_msu_carbon", underscored: true, paranoid: true }) -export class IndicatorOutputMsuCarbon extends Model { +export class IndicatorOutputMsuCarbon extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/indicator-output-tree-count.entity.ts b/libs/database/src/lib/entities/indicator-output-tree-count.entity.ts index a3e308e..ed465b0 100644 --- a/libs/database/src/lib/entities/indicator-output-tree-count.entity.ts +++ b/libs/database/src/lib/entities/indicator-output-tree-count.entity.ts @@ -4,7 +4,7 @@ import { SitePolygon } from "./site-polygon.entity"; import { INDICATOR_SLUGS, IndicatorSlug } from "../constants"; @Table({ tableName: "indicator_output_tree_count", underscored: true, paranoid: true }) -export class IndicatorOutputTreeCount extends Model { +export class IndicatorOutputTreeCount extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/indicator-output-tree-cover-loss.entity.ts b/libs/database/src/lib/entities/indicator-output-tree-cover-loss.entity.ts index 123abec..24d5012 100644 --- a/libs/database/src/lib/entities/indicator-output-tree-cover-loss.entity.ts +++ b/libs/database/src/lib/entities/indicator-output-tree-cover-loss.entity.ts @@ -4,7 +4,7 @@ import { SitePolygon } from "./site-polygon.entity"; import { INDICATOR_SLUGS, IndicatorSlug } from "../constants"; @Table({ tableName: "indicator_output_tree_cover_loss", underscored: true, paranoid: true }) -export class IndicatorOutputTreeCoverLoss extends Model { +export class IndicatorOutputTreeCoverLoss extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/indicator-output-tree-cover.entity.ts b/libs/database/src/lib/entities/indicator-output-tree-cover.entity.ts index 12c867f..508eb6e 100644 --- a/libs/database/src/lib/entities/indicator-output-tree-cover.entity.ts +++ b/libs/database/src/lib/entities/indicator-output-tree-cover.entity.ts @@ -4,7 +4,7 @@ import { SitePolygon } from "./site-polygon.entity"; import { INDICATOR_SLUGS, IndicatorSlug } from "../constants"; @Table({ tableName: "indicator_output_tree_cover", underscored: true, paranoid: true }) -export class IndicatorOutputTreeCover extends Model { +export class IndicatorOutputTreeCover extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/model-has-role.entity.ts b/libs/database/src/lib/entities/model-has-role.entity.ts index a537649..519b291 100644 --- a/libs/database/src/lib/entities/model-has-role.entity.ts +++ b/libs/database/src/lib/entities/model-has-role.entity.ts @@ -1,9 +1,9 @@ -import { Column, ForeignKey, Model, Table } from 'sequelize-typescript'; -import { Role } from './role.entity'; -import { BIGINT, STRING } from 'sequelize'; +import { Column, ForeignKey, Model, Table } from "sequelize-typescript"; +import { Role } from "./role.entity"; +import { BIGINT, STRING } from "sequelize"; -@Table({ tableName: 'model_has_roles', underscored: true, timestamps: false }) -export class ModelHasRole extends Model { +@Table({ tableName: "model_has_roles", underscored: true, timestamps: false }) +export class ModelHasRole extends Model { @ForeignKey(() => Role) @Column({ type: BIGINT.UNSIGNED, primaryKey: true }) roleId: number; diff --git a/libs/database/src/lib/entities/organisation-user.entity.ts b/libs/database/src/lib/entities/organisation-user.entity.ts index 2a4961e..77ee105 100644 --- a/libs/database/src/lib/entities/organisation-user.entity.ts +++ b/libs/database/src/lib/entities/organisation-user.entity.ts @@ -1,10 +1,10 @@ -import { AutoIncrement, Column, ForeignKey, Model, PrimaryKey, Table } from 'sequelize-typescript'; -import { BIGINT, STRING } from 'sequelize'; -import { Organisation } from './organisation.entity'; -import { User } from './user.entity'; +import { AutoIncrement, Column, ForeignKey, Model, PrimaryKey, Table } from "sequelize-typescript"; +import { BIGINT, STRING } from "sequelize"; +import { Organisation } from "./organisation.entity"; +import { User } from "./user.entity"; -@Table({ tableName: 'organisation_user', underscored: true, timestamps: false }) -export class OrganisationUser extends Model { +@Table({ tableName: "organisation_user", underscored: true, timestamps: false }) +export class OrganisationUser extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/organisation.entity.ts b/libs/database/src/lib/entities/organisation.entity.ts index f22f39d..4cfb401 100644 --- a/libs/database/src/lib/entities/organisation.entity.ts +++ b/libs/database/src/lib/entities/organisation.entity.ts @@ -2,7 +2,7 @@ import { AllowNull, AutoIncrement, Column, Default, Index, Model, PrimaryKey, Ta import { BIGINT, BOOLEAN, DATE, DECIMAL, ENUM, INTEGER, STRING, TEXT, TINYINT, UUID } from "sequelize"; @Table({ tableName: "organisations", underscored: true }) -export class Organisation extends Model { +export class Organisation extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/permission.entity.ts b/libs/database/src/lib/entities/permission.entity.ts index f7f4383..8694fa6 100644 --- a/libs/database/src/lib/entities/permission.entity.ts +++ b/libs/database/src/lib/entities/permission.entity.ts @@ -1,8 +1,8 @@ -import { AutoIncrement, Column, Model, PrimaryKey, Table } from 'sequelize-typescript'; -import { BIGINT, QueryTypes, STRING } from 'sequelize'; +import { AutoIncrement, Column, Model, PrimaryKey, Table } from "sequelize-typescript"; +import { BIGINT, QueryTypes, STRING } from "sequelize"; -@Table({ tableName: 'permissions', underscored: true }) -export class Permission extends Model { +@Table({ tableName: "permissions", underscored: true }) +export class Permission extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) @@ -35,8 +35,8 @@ export class Permission extends Model { model_has_roles.model_id = :modelId `, { - replacements: { modelType: 'App\\Models\\V2\\User', modelId: userId }, - type: QueryTypes.SELECT, + replacements: { modelType: "App\\Models\\V2\\User", modelId: userId }, + type: QueryTypes.SELECT } )) as { name: string }[]; diff --git a/libs/database/src/lib/entities/point-geometry.entity.ts b/libs/database/src/lib/entities/point-geometry.entity.ts index 6d37d3d..16822fe 100644 --- a/libs/database/src/lib/entities/point-geometry.entity.ts +++ b/libs/database/src/lib/entities/point-geometry.entity.ts @@ -4,7 +4,7 @@ import { Point } from "geojson"; import { User } from "./user.entity"; @Table({ tableName: "point_geometry", underscored: true, paranoid: true }) -export class PointGeometry extends Model { +export class PointGeometry extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/polygon-geometry.entity.ts b/libs/database/src/lib/entities/polygon-geometry.entity.ts index 27b3ea4..719ece0 100644 --- a/libs/database/src/lib/entities/polygon-geometry.entity.ts +++ b/libs/database/src/lib/entities/polygon-geometry.entity.ts @@ -4,7 +4,7 @@ import { Polygon } from "geojson"; import { User } from "./user.entity"; @Table({ tableName: "polygon_geometry", underscored: true, paranoid: true }) -export class PolygonGeometry extends Model { +export class PolygonGeometry extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/project-user.entity.ts b/libs/database/src/lib/entities/project-user.entity.ts index c2626a7..3f49d8d 100644 --- a/libs/database/src/lib/entities/project-user.entity.ts +++ b/libs/database/src/lib/entities/project-user.entity.ts @@ -1,18 +1,10 @@ -import { - AllowNull, - AutoIncrement, - Column, Default, - ForeignKey, - Model, - PrimaryKey, - Table -} from 'sequelize-typescript'; -import { Project } from './project.entity'; -import { User } from './user.entity'; -import { BIGINT, BOOLEAN, STRING } from 'sequelize'; +import { AllowNull, AutoIncrement, Column, Default, ForeignKey, Model, PrimaryKey, Table } from "sequelize-typescript"; +import { Project } from "./project.entity"; +import { User } from "./user.entity"; +import { BIGINT, BOOLEAN, STRING } from "sequelize"; -@Table({ tableName: 'v2_project_users', underscored: true }) -export class ProjectUser extends Model { +@Table({ tableName: "v2_project_users", underscored: true }) +export class ProjectUser extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/project.entity.ts b/libs/database/src/lib/entities/project.entity.ts index 05ec6e3..464a41f 100644 --- a/libs/database/src/lib/entities/project.entity.ts +++ b/libs/database/src/lib/entities/project.entity.ts @@ -3,7 +3,7 @@ import { BIGINT, BOOLEAN, STRING, UUID } from "sequelize"; // A quick stub to get the information needed for users/me @Table({ tableName: "v2_projects", underscored: true, paranoid: true }) -export class Project extends Model { +export class Project extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/role.entity.ts b/libs/database/src/lib/entities/role.entity.ts index 0a93c93..c18db6f 100644 --- a/libs/database/src/lib/entities/role.entity.ts +++ b/libs/database/src/lib/entities/role.entity.ts @@ -1,14 +1,8 @@ -import { - AutoIncrement, - Column, - Model, - PrimaryKey, - Table, -} from 'sequelize-typescript'; -import { BIGINT, STRING } from 'sequelize'; +import { AutoIncrement, Column, Model, PrimaryKey, Table } from "sequelize-typescript"; +import { BIGINT, STRING } from "sequelize"; -@Table({ tableName: 'roles', underscored: true }) -export class Role extends Model { +@Table({ tableName: "roles", underscored: true }) +export class Role extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/site-polygon.entity.ts b/libs/database/src/lib/entities/site-polygon.entity.ts index 9469237..5e4855c 100644 --- a/libs/database/src/lib/entities/site-polygon.entity.ts +++ b/libs/database/src/lib/entities/site-polygon.entity.ts @@ -33,7 +33,7 @@ export type Indicator = | IndicatorOutputMsuCarbon; @Table({ tableName: "site_polygon", underscored: true, paranoid: true }) -export class SitePolygon extends Model { +export class SitePolygon extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/src/lib/entities/user.entity.ts b/libs/database/src/lib/entities/user.entity.ts index ccc4858..282ea42 100644 --- a/libs/database/src/lib/entities/user.entity.ts +++ b/libs/database/src/lib/entities/user.entity.ts @@ -25,7 +25,7 @@ import { OrganisationUser } from "./organisation-user.entity"; import { FrameworkUser } from "./framework-user.entity"; @Table({ tableName: "users", underscored: true, paranoid: true }) -export class User extends Model { +export class User extends Model { @PrimaryKey @AutoIncrement @Column(BIGINT.UNSIGNED) diff --git a/libs/database/tsconfig.json b/libs/database/tsconfig.json index f5b8565..7678e97 100644 --- a/libs/database/tsconfig.json +++ b/libs/database/tsconfig.json @@ -7,7 +7,8 @@ "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": true, "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "strictPropertyInitialization": false }, "files": [], "include": [], diff --git a/setup-jest.ts b/setup-jest.ts deleted file mode 100644 index 37f6084..0000000 --- a/setup-jest.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Sequelize } from 'sequelize-typescript'; -import { FactoryGirl, SequelizeAdapter } from 'factory-girl-ts'; -import * as Entities from '@terramatch-microservices/database/entities'; - -let sequelize: Sequelize; - -beforeAll(async () => { - // To create this database, run the ./setup-test-database.sh script. - sequelize = new Sequelize({ - dialect: 'mariadb', - host: 'localhost', - port: 3360, - username: 'wri', - password: 'wri', - database: 'terramatch_microservices_test', - models: Object.values(Entities), - logging: false, - }) - - await sequelize.sync(); - FactoryGirl.setAdapter(new SequelizeAdapter()); -}); - -afterAll(async () => { - await sequelize.close(); -});