Skip to content

Commit 655abcd

Browse files
author
Evan Roman
committed
test
1 parent 655b7a3 commit 655abcd

File tree

9 files changed

+106
-108
lines changed

9 files changed

+106
-108
lines changed

__azurite_db_blob__.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

__azurite_db_blob_extent__.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// // Copyright (c) .NET Foundation. All rights reserved.
2-
// // Licensed under the MIT License.
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
33

4-
// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
4+
import { AzureFunction, Context, HttpRequest } from '@azure/functions';
55

6-
// const httpTriggerStorageQueueOutput: AzureFunction = async function (
7-
// context: Context,
8-
// request: HttpRequest
9-
// ): Promise<void> {
10-
// context.bindings.outputMsg = request.body.output;
11-
// context.res = { body: 'done' };
12-
// };
6+
const httpTriggerStorageQueueOutput: AzureFunction = async function (
7+
context: Context,
8+
request: HttpRequest
9+
): Promise<void> {
10+
context.bindings.outputMsg = request.body.output;
11+
context.res = { body: 'done' };
12+
};
1313

14-
// export default httpTriggerStorageQueueOutput;
14+
export default httpTriggerStorageQueueOutput;

app/v3/storageQueueTrigger/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// // Copyright (c) .NET Foundation. All rights reserved.
2-
// // Licensed under the MIT License.
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
33

4-
// import { AzureFunction, Context } from '@azure/functions';
4+
import { AzureFunction, Context } from '@azure/functions';
55

6-
// const queueTrigger: AzureFunction = async function (context: Context, myQueueItem: string): Promise<void> {
7-
// context.log(`storageQueueTrigger was triggered by "${myQueueItem}"`);
8-
// };
6+
const queueTrigger: AzureFunction = async function (context: Context, myQueueItem: string): Promise<void> {
7+
context.log(`storageQueueTrigger was triggered by "${myQueueItem}"`);
8+
};
99

10-
// export default queueTrigger;
10+
export default queueTrigger;
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// // Copyright (c) .NET Foundation. All rights reserved.
2-
// // Licensed under the MIT License.
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
33

4-
// import { AzureFunction, Context } from '@azure/functions';
4+
import { AzureFunction, Context } from '@azure/functions';
55

6-
// const queueTrigger: AzureFunction = async function (context: Context, myQueueItem: string): Promise<string> {
7-
// context.log(`storageQueueTriggerAndOutput was triggered by "${myQueueItem}"`);
8-
// return myQueueItem;
9-
// };
6+
const queueTrigger: AzureFunction = async function (context: Context, myQueueItem: string): Promise<string> {
7+
context.log(`storageQueueTriggerAndOutput was triggered by "${myQueueItem}"`);
8+
return myQueueItem;
9+
};
1010

11-
// export default queueTrigger;
11+
export default queueTrigger;
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
// // Copyright (c) .NET Foundation. All rights reserved.
2-
// // Licensed under the MIT License.
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
33

4-
// import { app, HttpRequest, HttpResponseInit, InvocationContext, output } from '@azure/functions';
4+
import { app, HttpRequest, HttpResponseInit, InvocationContext, output } from '@azure/functions';
55

6-
// const storageOutput = output.storageQueue({
7-
// queueName: 'e2e-test-queue-trigger',
8-
// connection: 'e2eTest_storage',
9-
// });
6+
const storageOutput = output.storageQueue({
7+
queueName: 'e2e-test-queue-trigger',
8+
connection: 'AzureWebJobsStorage',
9+
});
1010

11-
// export async function httpTriggerStorageQueueOutput(
12-
// request: HttpRequest,
13-
// context: InvocationContext
14-
// ): Promise<HttpResponseInit> {
15-
// const body = <{ output: any }>await request.json();
16-
// context.extraOutputs.set(storageOutput, body.output);
17-
// return { body: 'done' };
18-
// }
11+
export async function httpTriggerStorageQueueOutput(
12+
request: HttpRequest,
13+
context: InvocationContext
14+
): Promise<HttpResponseInit> {
15+
const body = <{ output: any }>await request.json();
16+
context.extraOutputs.set(storageOutput, body.output);
17+
return { body: 'done' };
18+
}
1919

20-
// app.http('httpTriggerStorageQueueOutput', {
21-
// methods: ['POST'],
22-
// authLevel: 'anonymous',
23-
// extraOutputs: [storageOutput],
24-
// handler: httpTriggerStorageQueueOutput,
25-
// });
20+
app.http('httpTriggerStorageQueueOutput', {
21+
methods: ['POST'],
22+
authLevel: 'anonymous',
23+
extraOutputs: [storageOutput],
24+
handler: httpTriggerStorageQueueOutput,
25+
});
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// // Copyright (c) .NET Foundation. All rights reserved.
2-
// // Licensed under the MIT License.
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
33

4-
// import { app, InvocationContext } from '@azure/functions';
4+
import { app, InvocationContext } from '@azure/functions';
55

6-
// export async function storageQueueTrigger(queueItem: string, context: InvocationContext): Promise<void> {
7-
// context.log(`storageQueueTrigger was triggered by "${queueItem}"`);
8-
// }
6+
export async function storageQueueTrigger(queueItem: string, context: InvocationContext): Promise<void> {
7+
context.log(`storageQueueTrigger was triggered by "${queueItem}"`);
8+
}
99

10-
// app.storageQueue('storageQueueTrigger', {
11-
// queueName: 'e2e-test-queue-trigger',
12-
// connection: 'e2eTest_storage',
13-
// handler: storageQueueTrigger,
14-
// });
10+
app.storageQueue('storageQueueTrigger', {
11+
queueName: 'e2e-test-queue-trigger',
12+
connection: 'AzureWebJobsStorage',
13+
handler: storageQueueTrigger,
14+
});
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
// // Copyright (c) .NET Foundation. All rights reserved.
2-
// // Licensed under the MIT License.
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
33

4-
// import { app, InvocationContext, output } from '@azure/functions';
4+
import { app, InvocationContext, output } from '@azure/functions';
55

6-
// export async function storageQueueTriggerAndOutput(queueItem: string, context: InvocationContext): Promise<string> {
7-
// context.log(`storageQueueTriggerAndOutput was triggered by "${queueItem}"`);
8-
// return queueItem;
9-
// }
6+
export async function storageQueueTriggerAndOutput(queueItem: string, context: InvocationContext): Promise<string> {
7+
context.log(`storageQueueTriggerAndOutput was triggered by "${queueItem}"`);
8+
return queueItem;
9+
}
1010

11-
// app.storageQueue('storageQueueTriggerAndOutput', {
12-
// queueName: 'e2e-test-queue-trigger-and-output',
13-
// connection: 'e2eTest_storage',
14-
// return: output.storageQueue({
15-
// queueName: 'e2e-test-queue-trigger',
16-
// connection: 'e2eTest_storage',
17-
// }),
18-
// handler: storageQueueTriggerAndOutput,
19-
// });
11+
app.storageQueue('storageQueueTriggerAndOutput', {
12+
queueName: 'e2e-test-queue-trigger-and-output',
13+
connection: 'AzureWebJobsStorage',
14+
return: output.storageQueue({
15+
queueName: 'e2e-test-queue-trigger',
16+
connection: 'AzureWebJobsStorage',
17+
}),
18+
handler: storageQueueTriggerAndOutput,
19+
});

src/storage.test.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,44 @@
22
// Licensed under the MIT License.
33

44
import { ContainerClient } from '@azure/storage-blob';
5-
// import { QueueClient } from '@azure/storage-queue';
5+
import { QueueClient } from '@azure/storage-queue';
66
// import { expect } from 'chai';
7-
// import { default as fetch } from 'node-fetch';
8-
// import { getFuncUrl } from './constants';
7+
import { default as fetch } from 'node-fetch';
8+
import { getFuncUrl } from './constants';
99
import { model, waitForOutput } from './global.test';
1010
import { getRandomTestData } from './utils/getRandomTestData';
1111
import { storageConnectionString } from './utils/connectionStrings';
1212

1313
describe('storage', () => {
14-
// it('queue trigger and output', async () => {
15-
// const client = new QueueClient(storageConnectionString, 'e2e-test-queue-trigger-and-output');
16-
// await client.createIfNotExists();
17-
18-
// const message = getRandomTestData();
19-
// await client.sendMessage(Buffer.from(message).toString('base64'));
20-
21-
// await waitForOutput(`storageQueueTriggerAndOutput was triggered by "${message}"`);
22-
// await waitForOutput(`storageQueueTrigger was triggered by "${message}"`);
23-
// });
24-
25-
// it('queue extra output', async () => {
26-
// const url = getFuncUrl('httpTriggerStorageQueueOutput');
27-
28-
// // single
29-
// const message = getRandomTestData();
30-
// await fetch(url, { method: 'POST', body: JSON.stringify({ output: message }) });
31-
// await waitForOutput(`storageQueueTrigger was triggered by "${message}"`);
32-
33-
// // bulk
34-
// const bulkMsgs: string[] = [];
35-
// for (let i = 0; i < 5; i++) {
36-
// bulkMsgs.push(getRandomTestData());
37-
// }
38-
// await fetch(url, { method: 'POST', body: JSON.stringify({ output: bulkMsgs }) });
39-
// for (const msg of bulkMsgs) {
40-
// await waitForOutput(`storageQueueTrigger was triggered by "${msg}"`);
41-
// }
42-
// });
14+
it('queue trigger and output', async () => {
15+
const client = new QueueClient(storageConnectionString, 'e2e-test-queue-trigger-and-output');
16+
await client.createIfNotExists();
17+
18+
const message = getRandomTestData();
19+
await client.sendMessage(Buffer.from(message).toString('base64'));
20+
21+
await waitForOutput(`storageQueueTriggerAndOutput was triggered by "${message}"`);
22+
await waitForOutput(`storageQueueTrigger was triggered by "${message}"`);
23+
});
24+
25+
it('queue extra output', async () => {
26+
const url = getFuncUrl('httpTriggerStorageQueueOutput');
27+
28+
// single
29+
const message = getRandomTestData();
30+
await fetch(url, { method: 'POST', body: JSON.stringify({ output: message }) });
31+
await waitForOutput(`storageQueueTrigger was triggered by "${message}"`);
32+
33+
// bulk
34+
const bulkMsgs: string[] = [];
35+
for (let i = 0; i < 5; i++) {
36+
bulkMsgs.push(getRandomTestData());
37+
}
38+
await fetch(url, { method: 'POST', body: JSON.stringify({ output: bulkMsgs }) });
39+
for (const msg of bulkMsgs) {
40+
await waitForOutput(`storageQueueTrigger was triggered by "${msg}"`);
41+
}
42+
});
4343

4444
it('blob trigger and output', async () => {
4545
const containerName = 'e2e-test-container';

0 commit comments

Comments
 (0)