diff --git a/packages/worker/src/api/routes/system/tests/migrations.spec.ts b/packages/worker/src/api/routes/system/tests/migrations.spec.ts deleted file mode 100644 index fe91a1070c..0000000000 --- a/packages/worker/src/api/routes/system/tests/migrations.spec.ts +++ /dev/null @@ -1,63 +0,0 @@ -const migrateFn = jest.fn() - -import { TestConfiguration } from "../../../../tests" - -jest.mock("../../../../migrations", () => { - return { - ...jest.requireActual("../../../../migrations"), - migrate: migrateFn, - } -}) - -describe("/api/system/migrations", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - }) - - afterAll(async () => { - await config.afterAll() - }) - - afterEach(() => { - jest.clearAllMocks() - }) - - describe("POST /api/system/migrations/run", () => { - it("fails with no internal api key", async () => { - const res = await config.api.migrations.runMigrations({ - headers: {}, - status: 403, - }) - expect(res.body).toEqual({ message: "Unauthorized", status: 403 }) - expect(migrateFn).toHaveBeenCalledTimes(0) - }) - - it("runs migrations", async () => { - const res = await config.api.migrations.runMigrations() - expect(res.body.message).toBeDefined() - expect(migrateFn).toHaveBeenCalledTimes(1) - }) - }) - - describe("DELETE /api/system/migrations/definitions", () => { - it("fails with no internal api key", async () => { - const res = await config.api.migrations.getMigrationDefinitions({ - headers: {}, - status: 403, - }) - expect(res.body).toEqual({ message: "Unauthorized", status: 403 }) - }) - - it("returns definitions", async () => { - const res = await config.api.migrations.getMigrationDefinitions() - expect(res.body).toEqual([ - { - name: "global_info_sync_users", - type: "global", - }, - ]) - }) - }) -}) diff --git a/packages/worker/src/tests/api/index.ts b/packages/worker/src/tests/api/index.ts index fa4e54184c..0f0334c8da 100644 --- a/packages/worker/src/tests/api/index.ts +++ b/packages/worker/src/tests/api/index.ts @@ -6,7 +6,6 @@ import { EmailAPI } from "./email" import { SelfAPI } from "./self" import { UserAPI } from "./users" import { EnvironmentAPI } from "./environment" -import { MigrationAPI } from "./migrations" import { StatusAPI } from "./status" import { RestoreAPI } from "./restore" import { TenantAPI } from "./tenants" @@ -26,7 +25,6 @@ export default class API { self: SelfAPI users: UserAPI environment: EnvironmentAPI - migrations: MigrationAPI status: StatusAPI restore: RestoreAPI tenants: TenantAPI @@ -46,7 +44,6 @@ export default class API { this.self = new SelfAPI(config) this.users = new UserAPI(config) this.environment = new EnvironmentAPI(config) - this.migrations = new MigrationAPI(config) this.status = new StatusAPI(config) this.restore = new RestoreAPI(config) this.tenants = new TenantAPI(config) diff --git a/packages/worker/src/tests/api/migrations.ts b/packages/worker/src/tests/api/migrations.ts deleted file mode 100644 index 6d62fe994a..0000000000 --- a/packages/worker/src/tests/api/migrations.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { TestAPI, TestAPIOpts } from "./base" - -export class MigrationAPI extends TestAPI { - runMigrations = (opts?: TestAPIOpts) => { - return this.request - .post(`/api/system/migrations/run`) - .set(opts?.headers ? opts.headers : this.config.internalAPIHeaders()) - .expect(opts?.status ? opts.status : 200) - } - - getMigrationDefinitions = (opts?: TestAPIOpts) => { - return this.request - .get(`/api/system/migrations/definitions`) - .set(opts?.headers ? opts.headers : this.config.internalAPIHeaders()) - .expect(opts?.status ? opts.status : 200) - } -}