mirror of https://github.com/Chocobozzz/PeerTube
Wait mock server termination
parent
6d210220be
commit
70430c2796
|
@ -243,7 +243,7 @@ function runTestSuite (options: {
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
mockObjectStorage.terminate()
|
await mockObjectStorage.terminate()
|
||||||
|
|
||||||
await cleanupTests(servers)
|
await cleanupTests(servers)
|
||||||
})
|
})
|
||||||
|
@ -380,8 +380,8 @@ describe('Object storage for videos', function () {
|
||||||
playlistBucket: 'mybucket',
|
playlistBucket: 'mybucket',
|
||||||
webtorrentBucket: 'mybucket',
|
webtorrentBucket: 'mybucket',
|
||||||
|
|
||||||
playlistPrefix: 'streaming-playlists_',
|
playlistPrefix: 'streaming-playlists/',
|
||||||
webtorrentPrefix: 'webtorrent_',
|
webtorrentPrefix: 'webtorrent/',
|
||||||
|
|
||||||
useMockBaseUrl: true
|
useMockBaseUrl: true
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,7 +65,7 @@ describe('Test proxy', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
proxy.terminate()
|
await proxy.terminate()
|
||||||
|
|
||||||
await cleanupTests(servers)
|
await cleanupTests(servers)
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Server } from 'http'
|
||||||
import { pipeline } from 'stream'
|
import { pipeline } from 'stream'
|
||||||
import { randomInt } from '@shared/core-utils'
|
import { randomInt } from '@shared/core-utils'
|
||||||
import { ObjectStorageCommand } from '../server'
|
import { ObjectStorageCommand } from '../server'
|
||||||
|
import { terminateServer } from './utils'
|
||||||
|
|
||||||
export class MockObjectStorage {
|
export class MockObjectStorage {
|
||||||
private server: Server
|
private server: Server
|
||||||
|
@ -37,6 +38,6 @@ export class MockObjectStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
terminate () {
|
terminate () {
|
||||||
if (this.server) this.server.close()
|
return terminateServer(this.server)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import express, { Request, Response } from 'express'
|
import express, { Request, Response } from 'express'
|
||||||
import { Server } from 'http'
|
import { Server } from 'http'
|
||||||
import { randomInt } from '@shared/core-utils'
|
import { randomInt } from '@shared/core-utils'
|
||||||
|
import { terminateServer } from './utils'
|
||||||
|
|
||||||
type BlocklistResponse = {
|
type BlocklistResponse = {
|
||||||
data: {
|
data: {
|
||||||
|
@ -32,6 +33,6 @@ export class MockBlocklist {
|
||||||
}
|
}
|
||||||
|
|
||||||
terminate () {
|
terminate () {
|
||||||
if (this.server) this.server.close()
|
return terminateServer(this.server)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { createServer, Server } from 'http'
|
import { createServer, Server } from 'http'
|
||||||
import proxy from 'proxy'
|
import proxy from 'proxy'
|
||||||
import { randomInt } from '@shared/core-utils'
|
import { randomInt } from '@shared/core-utils'
|
||||||
|
import { terminateServer } from './utils'
|
||||||
|
|
||||||
class MockProxy {
|
class MockProxy {
|
||||||
private server: Server
|
private server: Server
|
||||||
|
@ -16,7 +17,7 @@ class MockProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
terminate () {
|
terminate () {
|
||||||
if (this.server) this.server.close()
|
return terminateServer(this.server)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { Server } from 'http'
|
||||||
|
|
||||||
|
function terminateServer (server: Server) {
|
||||||
|
if (!server) return Promise.resolve()
|
||||||
|
|
||||||
|
return new Promise<void>((res, rej) => {
|
||||||
|
server.close(err => {
|
||||||
|
if (err) return rej(err)
|
||||||
|
|
||||||
|
return res()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
terminateServer
|
||||||
|
}
|
Loading…
Reference in New Issue