Skip to content

Commit 0171407

Browse files
authored
Merge pull request #67 from OpenFunction/feature/dapr-180
2 parents 351c639 + d44a6d5 commit 0171407

File tree

6 files changed

+89
-80
lines changed

6 files changed

+89
-80
lines changed

.github/workflows/unit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
node-version: [16]
12-
dapr-version: [1.6.3, 1.7.4]
12+
dapr-version: [1.6.3, 1.7.4, 1.8.0]
1313
platform: [ubuntu-latest]
1414
runs-on: ${{ matrix.platform }}
1515
steps:

docs/generated/api.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"metadata": {
33
"toolPackage": "@microsoft/api-extractor",
4-
"toolVersion": "7.27.0",
5-
"schemaVersion": 1008,
4+
"toolVersion": "7.28.4",
5+
"schemaVersion": 1009,
66
"oldestForwardsCompatibleVersion": 1001,
77
"tsdocConfig": {
88
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
@@ -1602,6 +1602,7 @@
16021602
"text": ";"
16031603
}
16041604
],
1605+
"isReadonly": false,
16051606
"returnTypeTokenRange": {
16061607
"startIndex": 3,
16071608
"endIndex": 4

package-lock.json

Lines changed: 53 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"express": "^4.18.1",
2121
"express-interceptor": "^1.2.0",
2222
"lodash": "^4.17.21",
23-
"minimist": "^1.2.5",
24-
"on-finished": "^2.3.0",
23+
"minimist": "^1.2.6",
24+
"on-finished": "^2.4.1",
2525
"read-pkg-up": "^7.0.1",
26-
"semver": "^7.3.5"
26+
"semver": "^7.3.7"
2727
},
2828
"scripts": {
2929
"test": "cross-env DEBUG=common:*,ofn:* mocha build/test -t 60000 --recursive --exit",
@@ -52,7 +52,7 @@
5252
"author": "OpenFunction",
5353
"license": "Apache-2.0",
5454
"devDependencies": {
55-
"@microsoft/api-extractor": "^7.27.0",
55+
"@microsoft/api-extractor": "^7.28.4",
5656
"@types/body-parser": "1.19.2",
5757
"@types/debug": "^4.1.7",
5858
"@types/express": "4.17.13",
@@ -65,16 +65,16 @@
6565
"@types/on-finished": "2.3.1",
6666
"@types/semver": "^7.3.10",
6767
"@types/shelljs": "^0.8.11",
68-
"@types/sinon": "^10.0.11",
68+
"@types/sinon": "10.0.11",
6969
"@types/supertest": "2.0.12",
7070
"aedes": "^0.47.0",
71-
"concurrently": "^7.2.2",
71+
"concurrently": "^7.3.0",
7272
"cross-env": "^7.0.3",
7373
"env-cmd": "^10.1.0",
7474
"gts": "^3.1.0",
7575
"mocha": "10.0.0",
7676
"pack-n-play": "^1.0.0-2",
77-
"pre-push": "^0.1.2",
77+
"pre-push": "^0.1.3",
7878
"shelljs": "^0.8.5",
7979
"sinon": "^14.0.0",
8080
"supertest": "6.2.3",

test/integration/async_server.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import {deepStrictEqual, ifError, ok} from 'assert';
33
import {createServer} from 'net';
44

5-
import {get} from 'lodash';
5+
import {get, isEmpty} from 'lodash';
66
import * as shell from 'shelljs';
77
import * as MQTT from 'aedes';
88

@@ -54,7 +54,16 @@ const TEST_CONTEXT: OpenFunctionContext = {
5454
},
5555
},
5656
};
57+
5758
const TEST_PAYLOAD = {data: 'hello world'};
59+
const TEST_CLOUD_EVENT = {
60+
specversion: '1.0',
61+
id: 'test-1234-1234',
62+
type: 'ce.openfunction',
63+
source: 'https://github.com/OpenFunction/functions-framework-nodejs',
64+
traceparent: '00-65088630f09e0a5359677a7429456db7-97f23477fb2bf5ec-01',
65+
data: TEST_PAYLOAD,
66+
};
5867

5968
describe('OpenFunction - Async - Binding', () => {
6069
const APPID = 'async.dapr';
@@ -139,15 +148,12 @@ describe('OpenFunction - Async - Binding', () => {
139148

140149
it('mqtt sub w/ pub output', done => {
141150
const app = getAysncServer((ctx, data) => {
151+
if (isEmpty(data)) return;
152+
142153
// Assert that user function receives correct data from input binding
143-
try {
144-
const recieved = JSON.parse(data as string);
145-
deepStrictEqual(recieved, TEST_PAYLOAD);
146-
} catch (err) {
147-
ifError(err);
148-
}
154+
deepStrictEqual(data, TEST_PAYLOAD);
149155

150-
// Then write recived data to a local file
156+
// Then forward received data to output channel
151157
const output = 'mqtt_pub';
152158
broker.subscribe(
153159
get(TEST_CONTEXT, `outputs.${output}.uri`),
@@ -165,15 +171,17 @@ describe('OpenFunction - Async - Binding', () => {
165171

166172
// First, we start the async server
167173
app.start().then(() => {
168-
// Then, we publish a message via Dapr CLI
169-
const formatted = JSON.stringify(TEST_PAYLOAD).replace(/"/g, '\\"');
170-
shell.exec(
171-
`dapr publish -i ${APPID} -p ${
172-
TEST_CONTEXT.inputs!.mqtt_sub!.componentName
173-
} -t ${TEST_CONTEXT.inputs!.mqtt_sub.uri} -d '"${formatted}"'`,
174+
// Then, we send a cloudevent format message to server
175+
broker.publish(
174176
{
175-
silent: true,
176-
}
177+
cmd: 'publish',
178+
topic: TEST_CONTEXT.inputs!.mqtt_sub.uri!,
179+
payload: JSON.stringify(TEST_CLOUD_EVENT),
180+
qos: 0,
181+
retain: false,
182+
dup: false,
183+
},
184+
err => ifError(err)
177185
);
178186
});
179187
});

test/integration/cloud_event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {FUNCTION_STATUS_HEADER_FIELD} from '../../src/types';
2525
const TEST_CLOUD_EVENT = {
2626
specversion: '1.0',
2727
type: 'com.google.cloud.storage',
28-
source: 'https://github.com/GoogleCloudPlatform/functions-framework-nodejs',
28+
source: 'https://github.com/OpenFunction/functions-framework-nodejs',
2929
subject: 'test-subject',
3030
id: 'test-1234-1234',
3131
time: '2020-05-13T01:23:45Z',

0 commit comments

Comments
 (0)