add tests

This commit is contained in:
undefined committed 2020-08-10 18:51:07 +08:00
1 parent 081a75af8c
commit 54a57d3ca9
8 files changed
+27 -16

No files matched your search

+2 -8
View File
@@ -52,12 +52,6 @@ class Loader {
<input name="name" type="text" value="hydro">
</label>
</div></div>
<div class="row"><div class="columns">
<label class="inverse material textbox">
{{ _('Table Prefix') }}
<input name="prefix" type="text" placeholder="{{ _('Leave blank if none') }}">>
</label>
</div></div>
<div class="row"><div class="columns">
<label class="inverse material textbox">
{{ _('Database Username') }}
@@ -109,7 +103,7 @@ async function get(ctx: Context) {
async function post(ctx: Context) {
const {
host, port, name, username, password, prefix,
host, port, name, username, password,
} = ctx.request.body;
let mongourl = 'mongodb://';
if (username) mongourl += `${username}:${password}@`;
@@ -119,7 +113,7 @@ async function post(ctx: Context) {
useNewUrlParser: true, useUnifiedTopology: true,
});
const db = Database.db(name);
const coll = prefix ? db.collection('system') : db.collection(`${prefix}.system`);
const coll = db.collection('system');
await Promise.all([
coll.updateOne(
{ _id: 'server.host' },