Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for shared output bug #30

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions app/v4/src/functions/storageBlobTriggerSharedOutputBug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

import { app, InvocationContext, output } from '@azure/functions';

// Test for bug https://github.com/Azure/azure-functions-nodejs-library/issues/179

const queueOutput = output.storageQueue({
queueName: 'e2e-test-queue-trigger',
connection: 'e2eTest_storage',
});

app.storageBlob('storageBlobTriggerReturnOutput', {
path: 'e2e-test-container/e2e-test-blob-trigger-shared-output-bug',
connection: 'e2eTest_storage',
return: queueOutput,
handler: (blob: Buffer, context: InvocationContext) => {
context.log(`storageBlobTriggerReturnOutput was triggered`);
return `${blob.toString()}-returnOutput`;
},
});

app.storageBlob('storageBlobTriggerExtraOutput', {
path: 'e2e-test-container/e2e-test-blob-trigger-shared-output-bug',
connection: 'e2eTest_storage',
extraOutputs: [queueOutput],
handler: (blob: Buffer, context: InvocationContext) => {
context.log(`storageBlobTriggerExtraOutput was triggered`);
context.extraOutputs.set(queueOutput, `${blob.toString()}-extraOutput`);
},
});
23 changes: 22 additions & 1 deletion src/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { QueueClient } from '@azure/storage-queue';
import { expect } from 'chai';
import { default as fetch } from 'node-fetch';
import { getFuncUrl } from './constants';
import { waitForOutput } from './global.test';
import { model, waitForOutput } from './global.test';
import { storageConnectionString } from './resources/connectionStrings';
import { getRandomTestData } from './utils/getRandomTestData';

Expand Down Expand Up @@ -83,4 +83,25 @@ describe('storage', () => {
expect(result).to.deep.equal(items);
await waitForOutput(`httpTriggerTableInput was triggered`);
});

// Test for bug https://github.com/Azure/azure-functions-nodejs-library/issues/179
it('Shared output bug', async function (this: Mocha.Context) {
if (model === 'v3') {
this.skip();
}

const containerName = 'e2e-test-container';
const client = new ContainerClient(storageConnectionString, containerName);
await client.createIfNotExists();

const message = getRandomTestData();
const messageBuffer = Buffer.from(message);
const blobName = 'e2e-test-blob-trigger-shared-output-bug';
await client.uploadBlockBlob(blobName, messageBuffer, messageBuffer.byteLength);

await waitForOutput(`storageBlobTriggerReturnOutput was triggered`);
await waitForOutput(`storageBlobTriggerExtraOutput was triggered`);
await waitForOutput(`storageQueueTrigger was triggered by "${message}-returnOutput"`);
await waitForOutput(`storageQueueTrigger was triggered by "${message}-extraOutput"`);
});
});
Loading