Skip to content

Commit

Permalink
add additional assertions to lifecycle test
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Dec 4, 2023
1 parent e9a8b4e commit 876b628
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions test-e2e/media-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,55 @@ test('start/stop lifecycle', async (t) => {
coreStorage: () => new RAM(),
})

const project = await manager.getProject(await manager.createProject())

await manager.startMediaServer()

const blobUrl1 = await project.$blobs.getUrl({
driveId: randomBytes(32).toString('hex'),
name: randomBytes(8).toString('hex'),
type: 'photo',
variant: 'original',
})
const response1 = await fetch(blobUrl1)
t.is(response1.status, 404, 'server started and listening')

await manager.startMediaServer()

const blobUrl2 = await project.$blobs.getUrl({
driveId: randomBytes(32).toString('hex'),
name: randomBytes(8).toString('hex'),
type: 'video',
variant: 'original',
})
t.is(
new URL(blobUrl1).port,
new URL(blobUrl2).port,
'server port is the same'
)

await manager.stopMediaServer()

await t.exception.all(async () => {
await fetch(blobUrl2)
}, 'failed to fetch due to connection error')

await manager.startMediaServer()

const blobUrl3 = await project.$blobs.getUrl({
driveId: randomBytes(32).toString('hex'),
name: randomBytes(8).toString('hex'),
type: 'audio',
variant: 'original',
})
const response3 = await fetch(blobUrl3)
t.is(response3.status, 404, 'server started and listening')

await manager.stopMediaServer()

t.pass(
'startMediaServer() and stopMediaServer() life cycle runs without issues'
)
await t.exception.all(async () => {
await fetch(blobUrl3)
}, 'failed to fetch due to connection error')
})

test('retrieving blobs using url', async (t) => {
Expand Down

0 comments on commit 876b628

Please sign in to comment.