aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/miscs
diff options
context:
space:
mode:
authorbuoyantair <buoyantair@protonmail.com>2018-11-16 02:37:16 +0530
committerbuoyantair <buoyantair@protonmail.com>2018-11-16 02:37:16 +0530
commitae28cdf327d782e629379eee1999096ca2a5d74b (patch)
treebfe0d4b3a232d75161fe5bba9196553a388fc02a /server/tests/utils/miscs
parentd4681c0074ba51c62a3aeb9fb3f2cd071dd21e32 (diff)
parent8cf998733496d44fa564e2e252356b871756c984 (diff)
downloadPeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.tar.gz
PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.tar.zst
PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.zip
Merge from upstream
Diffstat (limited to 'server/tests/utils/miscs')
-rw-r--r--server/tests/utils/miscs/sql.ts38
-rw-r--r--server/tests/utils/miscs/stubs.ts14
2 files changed, 52 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..027f78131
--- /dev/null
+++ b/server/tests/utils/miscs/sql.ts
@@ -0,0 +1,38 @@
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
27function setVideoField (serverNumber: number, uuid: string, field: string, value: string) {
28 const seq = getSequelize(serverNumber)
29
30 const options = { type: Sequelize.QueryTypes.UPDATE }
31
32 return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
33}
34
35export {
36 setVideoField,
37 setActorField
38}
diff --git a/server/tests/utils/miscs/stubs.ts b/server/tests/utils/miscs/stubs.ts
new file mode 100644
index 000000000..d1eb0e3b2
--- /dev/null
+++ b/server/tests/utils/miscs/stubs.ts
@@ -0,0 +1,14 @@
1function buildRequestStub (): any {
2 return { }
3}
4
5function buildResponseStub (): any {
6 return {
7 locals: {}
8 }
9}
10
11export {
12 buildResponseStub,
13 buildRequestStub
14}