mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 18:39:32 +00:00
Add TestTemplate.createTestTemplate
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
/* eslint-disable no-empty-function, getter-return */
|
/* eslint-disable no-empty-function, getter-return */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
// Import user defined modules
|
// Import user defined modules
|
||||||
const DatabaseConnectionPool = require('./DatabaseConnectionPool');
|
const DatabaseConnectionPool = require('./DatabaseConnectionPool');
|
||||||
|
|
||||||
@@ -86,8 +88,31 @@ class TestTemplate {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static createTestTemplate() {
|
static async createTestTemplate(accountId, name, maxMark) {
|
||||||
|
const a = await new (require('./Account'))(accountId);
|
||||||
|
|
||||||
|
const id = crypto.randomUUID();
|
||||||
|
|
||||||
|
const conn = await new DatabaseConnectionPool();
|
||||||
|
|
||||||
|
const sql = `
|
||||||
|
insert into testTemplate(
|
||||||
|
testTemplateId,
|
||||||
|
accountId,
|
||||||
|
name,
|
||||||
|
maxMark)
|
||||||
|
values
|
||||||
|
(?, ?, ?, ?);
|
||||||
|
`;
|
||||||
|
|
||||||
|
await conn.runQuery(sql, [
|
||||||
|
id,
|
||||||
|
a.id,
|
||||||
|
name,
|
||||||
|
maxMark
|
||||||
|
]);
|
||||||
|
|
||||||
|
return new TestTemplate(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user