-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mariano Goldman
committed
Jan 22, 2024
1 parent
56f4249
commit 7a9e056
Showing
3 changed files
with
50 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,61 @@ | ||
import { test } from '../components' | ||
import { stringToUtf8Bytes } from 'eth-connect' | ||
import { Authenticator } from '@dcl/crypto' | ||
import { DeploymentToSqs } from '@dcl/schemas/dist/misc/deployments-to-sqs' | ||
|
||
test('reprocess asset-bundles handler /reprocess-ab', function ({ components, stubComponents }) { | ||
beforeEach(async () => { | ||
const { config } = stubComponents | ||
config.getString.withArgs('SNS_ARN').resolves('some-arn') | ||
}) | ||
|
||
it('when world exists it responds', async () => { | ||
it('can reprocess all worlds', async () => { | ||
const { localFetch, worldCreator } = components | ||
const { snsClient } = stubComponents | ||
|
||
const files = new Map<string, Uint8Array>() | ||
files.set('abc.png', Buffer.from(stringToUtf8Bytes('Hello world'))) | ||
const { entityId, owner } = await worldCreator.createWorldWithScene({}) | ||
const authChain = Authenticator.signPayload(owner, entityId) | ||
|
||
const { entityId, worldName, entity } = await worldCreator.createWorldWithScene({}) | ||
snsClient.publishBatch.resolves({ | ||
Successful: [{ Id: 'mocked-id', MessageId: 'mocked-message-id', SequenceNumber: '1' }], | ||
Failed: [], | ||
$metadata: {} | ||
}) | ||
|
||
const r = await localFetch | ||
.fetch(`/reprocess-ab`, { | ||
method: 'POST', | ||
headers: { | ||
Authorization: 'Bearer setup_some_secret_here' | ||
const r = await localFetch.fetch(`/reprocess-ab`, { | ||
method: 'POST', | ||
headers: { | ||
Authorization: 'Bearer setup_some_secret_here' | ||
} | ||
}) | ||
|
||
const baseUrl = `http://0.0.0.0:3000` | ||
expect(r.status).toEqual(200) | ||
expect(await r.json()).toMatchObject({ | ||
baseUrl: baseUrl, | ||
batch: expect.arrayContaining<DeploymentToSqs>([ | ||
{ | ||
entity: { | ||
entityId, | ||
authChain | ||
}, | ||
contentServerUrls: [baseUrl] | ||
} | ||
}) | ||
.catch(console.error) | ||
|
||
// console.log(r.status, r.statusText) | ||
// expect(r.status).toEqual(200) | ||
// expect(await r.json()).toEqual({ | ||
// name: worldName | ||
// }) | ||
]), | ||
successful: 1, | ||
failed: 0 | ||
}) | ||
}) | ||
|
||
it('can not be called if no SNS_ARN configured', async () => { | ||
const { localFetch } = components | ||
|
||
const r = await localFetch.fetch(`/reprocess-ab`, { | ||
method: 'POST', | ||
headers: { | ||
Authorization: 'Bearer setup_some_secret_here' | ||
} | ||
}) | ||
expect(r.status).toEqual(500) | ||
expect(await r.json()).toMatchObject({ error: 'Internal Server Error' }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters