28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
|
const ExitCodes = require('../../exit-codes/exit-codes.js');
|
||
|
|
||
|
const LOG = require('../../logger/logger.js')('setup-test-server');
|
||
|
const DB = require('../db.js');
|
||
|
|
||
|
process.on('unhandledRejection', async (reason, promise) => {
|
||
|
LOG.error('unhandled promise rejection:', reason);
|
||
|
ExitCodes.exit(ExitCodes.GENERAL_ERROR);
|
||
|
});
|
||
|
|
||
|
(async () => {
|
||
|
await DB.connect();
|
||
|
try {
|
||
|
let servers = await DB.getAllServers();
|
||
|
let targetServer = servers.find(server => server.name == 'no chicoms');
|
||
|
let members = await DB.getMembers(targetServer.id);
|
||
|
let targetMember = members.find(member => member.display_name == 'Elipzer');
|
||
|
let channels = await DB.getChannels(targetServer.id);
|
||
|
let targetChannel = channels.find(channel => channel.name == 'memes');
|
||
|
for (let i = 0; i < 2000; ++i) {
|
||
|
await DB.insertMessage(targetServer.id, targetChannel.id, targetMember.id, 'Test Message #' + i);
|
||
|
}
|
||
|
LOG.info('inserted testing messages');
|
||
|
} catch (e) {
|
||
|
LOG.error('error inserting messages', e);
|
||
|
}
|
||
|
await DB.end();
|
||
|
})();
|