2023-05-05 05:29:08 +00:00
|
|
|
// @ts-check
|
|
|
|
|
2023-08-18 05:00:40 +00:00
|
|
|
const fs = require("fs")
|
2023-09-30 12:24:05 +00:00
|
|
|
const {join} = require("path")
|
2023-05-05 05:29:08 +00:00
|
|
|
const sqlite = require("better-sqlite3")
|
2023-09-30 12:24:05 +00:00
|
|
|
const migrate = require("../db/migrate")
|
2023-05-05 05:29:08 +00:00
|
|
|
const HeatSync = require("heatsync")
|
2023-09-30 12:24:05 +00:00
|
|
|
const {test} = require("supertape")
|
|
|
|
const data = require("./data")
|
2023-05-05 05:29:08 +00:00
|
|
|
|
|
|
|
const config = require("../config")
|
|
|
|
const passthrough = require("../passthrough")
|
2023-08-18 05:00:40 +00:00
|
|
|
const db = new sqlite(":memory:")
|
|
|
|
|
2023-09-12 09:37:36 +00:00
|
|
|
const reg = require("../matrix/read-registration")
|
|
|
|
reg.ooye.server_origin = "https://matrix.cadence.moe" // so that tests will pass even when hard-coded
|
2024-01-20 05:23:48 +00:00
|
|
|
reg.ooye.server_name = "cadence.moe"
|
2023-10-12 11:51:38 +00:00
|
|
|
reg.ooye.invite = ["@test_auto_invite:example.org"]
|
2023-09-12 09:37:36 +00:00
|
|
|
|
2023-05-08 05:22:20 +00:00
|
|
|
const sync = new HeatSync({watchFS: false})
|
2023-05-05 05:29:08 +00:00
|
|
|
|
2023-09-30 12:24:05 +00:00
|
|
|
const discord = {
|
|
|
|
guilds: new Map([
|
|
|
|
[data.guild.general.id, data.guild.general]
|
2023-10-10 01:03:53 +00:00
|
|
|
]),
|
|
|
|
application: {
|
|
|
|
id: "684280192553844747"
|
2023-11-30 03:27:40 +00:00
|
|
|
},
|
|
|
|
channels: new Map([
|
|
|
|
["497161350934560778", {
|
|
|
|
guild_id: "497159726455455754"
|
|
|
|
}]
|
|
|
|
])
|
2023-09-30 12:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Object.assign(passthrough, { discord, config, sync, db })
|
2023-05-05 05:29:08 +00:00
|
|
|
|
2023-09-14 00:32:27 +00:00
|
|
|
const orm = sync.require("../db/orm")
|
|
|
|
passthrough.from = orm.from
|
|
|
|
passthrough.select = orm.select
|
|
|
|
|
2023-08-18 05:00:40 +00:00
|
|
|
const file = sync.require("../matrix/file")
|
|
|
|
file._actuallyUploadDiscordFileToMxc = function(url, res) { throw new Error(`Not allowed to upload files during testing.\nURL: ${url}`) }
|
|
|
|
|
2023-09-30 12:24:05 +00:00
|
|
|
;(async () => {
|
|
|
|
const p = migrate.migrate(db)
|
|
|
|
test("migrate: migration works", async t => {
|
|
|
|
await p
|
|
|
|
t.pass("it did not throw an error")
|
|
|
|
})
|
|
|
|
await p
|
2024-02-02 02:55:02 +00:00
|
|
|
|
|
|
|
test("migrate: migration works the second time", async t => {
|
|
|
|
await migrate.migrate(db)
|
|
|
|
t.pass("it did not throw an error")
|
|
|
|
})
|
|
|
|
|
2023-09-30 12:24:05 +00:00
|
|
|
db.exec(fs.readFileSync(join(__dirname, "ooye-test-data.sql"), "utf8"))
|
|
|
|
require("../db/orm.test")
|
2023-11-23 03:11:46 +00:00
|
|
|
require("../discord/utils.test")
|
2023-09-30 12:24:05 +00:00
|
|
|
require("../matrix/kstate.test")
|
|
|
|
require("../matrix/api.test")
|
|
|
|
require("../matrix/file.test")
|
|
|
|
require("../matrix/read-registration.test")
|
|
|
|
require("../matrix/txnid.test")
|
2023-10-14 09:08:10 +00:00
|
|
|
require("../d2m/actions/create-room.test")
|
|
|
|
require("../d2m/actions/register-user.test")
|
|
|
|
require("../d2m/converters/edit-to-changes.test")
|
|
|
|
require("../d2m/converters/emoji-to-key.test")
|
2024-01-18 03:54:09 +00:00
|
|
|
require("../d2m/converters/lottie.test")
|
2023-09-30 12:24:05 +00:00
|
|
|
require("../d2m/converters/message-to-event.test")
|
|
|
|
require("../d2m/converters/message-to-event.embeds.test")
|
2024-02-02 02:55:02 +00:00
|
|
|
require("../d2m/converters/message-to-event.pk.test")
|
2023-10-10 04:41:53 +00:00
|
|
|
require("../d2m/converters/pins-to-list.test")
|
2023-10-10 01:03:53 +00:00
|
|
|
require("../d2m/converters/remove-reaction.test")
|
2023-09-30 12:24:05 +00:00
|
|
|
require("../d2m/converters/thread-to-announcement.test")
|
|
|
|
require("../d2m/converters/user-to-mxid.test")
|
|
|
|
require("../m2d/converters/event-to-message.test")
|
|
|
|
require("../m2d/converters/utils.test")
|
2024-02-01 03:38:17 +00:00
|
|
|
require("../m2d/converters/emoji-sheet.test")
|
2023-09-30 12:24:05 +00:00
|
|
|
})()
|