Remove unused test.

This commit is contained in:
Sam Rose 2025-01-15 17:45:28 +00:00
parent 80fbaa1599
commit ff4f8f1d66
No known key found for this signature in database
3 changed files with 0 additions and 83 deletions

View File

@ -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",
},
])
})
})
})

View File

@ -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)

View File

@ -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)
}
}