aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/miscs/sql.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils/miscs/sql.ts')
-rw-r--r--server/tests/utils/miscs/sql.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/server/tests/utils/miscs/sql.ts b/server/tests/utils/miscs/sql.ts
new file mode 100644
index 000000000..204ff5163
--- /dev/null
+++ b/server/tests/utils/miscs/sql.ts
@@ -0,0 +1,29 @@
1import * as Sequelize from 'sequelize'
2
3function getSequelize (serverNumber: number) {
4 const dbname = 'peertube_test' + serverNumber
5 const username = 'peertube'
6 const password = 'peertube'
7 const host = 'localhost'
8 const port = 5432
9
10 return new Sequelize(dbname, username, password, {
11 dialect: 'postgres',
12 host,
13 port,
14 operatorsAliases: false,
15 logging: false
16 })
17}
18
19function setActorField (serverNumber: number, to: string, field: string, value: string) {
20 const seq = getSequelize(serverNumber)
21
22 const options = { type: Sequelize.QueryTypes.UPDATE }
23
24 return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options)
25}
26
27export {
28 setActorField
29}