mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 16:19:26 +00:00
Add TestTemplate.createTestTemplate
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
/* eslint-disable no-empty-function, getter-return */
|
||||
'use strict';
|
||||
|
||||
const crypto = require('crypto');
|
||||
|
||||
// Import user defined modules
|
||||
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