Skip to content

Commit e087805

Browse files
authored
test: use header constants in unmarshaller tests (cloudevents#60)
This commit updates the http unmarshaller tests to use the constants available in lib/bindings/http/constants.js. Signed-off-by: Daniel Bevenius <[email protected]>
1 parent 5110ad4 commit e087805

File tree

1 file changed

+41
-36
lines changed

1 file changed

+41
-36
lines changed

test/bindings/http/unmarshaller_0_3_tests.js

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const source = "urn:event:from:myapi/resourse/123";
88
const now = new Date();
99
const schemaurl = "http://cloudevents.io/schema.json";
1010
const subject = "subject.ext";
11+
const {
12+
BINARY_HEADERS_03,
13+
HEADER_CONTENT_TYPE
14+
} = require("../../../lib/bindings/http/constants.js");
15+
1116
const ceContentType = "application/json";
1217

1318
const data = {
@@ -176,13 +181,13 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
176181
data: "dataString"
177182
};
178183
var attributes = {
179-
"ce-type": "type",
180-
"ce-specversion": "0.3",
181-
"ce-source": "source",
182-
"ce-id": "id",
183-
"ce-time": "2019-06-16T11:42:00Z",
184-
"ce-schemaurl": "http://schema.registry/v1",
185-
"Content-Type": "text/html"
184+
[BINARY_HEADERS_03.TYPE]: "type",
185+
[BINARY_HEADERS_03.SPEC_VERSION]: "0.3",
186+
[BINARY_HEADERS_03.SOURCE]: "source",
187+
[BINARY_HEADERS_03.ID]: "id",
188+
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
189+
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
190+
[HEADER_CONTENT_TYPE]: "text/html"
186191
};
187192

188193
var un = new Unmarshaller();
@@ -200,13 +205,13 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
200205
data: "dataString"
201206
};
202207
var attributes = {
203-
"ce-type": "type",
208+
[BINARY_HEADERS_03.TYPE]: "type",
204209
"CE-CloudEventsVersion": "0.1",
205-
"ce-source": "source",
206-
"ce-id": "id",
207-
"ce-time": "2019-06-16T11:42:00Z",
208-
"ce-schemaurl": "http://schema.registry/v1",
209-
"Content-Type": "application/json"
210+
[BINARY_HEADERS_03.SOURCE]: "source",
211+
[BINARY_HEADERS_03.ID]: "id",
212+
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
213+
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
214+
[HEADER_CONTENT_TYPE]: "application/json"
210215
};
211216

212217
var un = new Unmarshaller();
@@ -224,13 +229,13 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
224229
data: "dataString"
225230
};
226231
var attributes = {
227-
"ce-type": "type",
228-
"ce-specversion": "0.3",
229-
"ce-source": "source",
230-
"ce-id": "id",
231-
"ce-time": "2019-06-16T11:42:00Z",
232-
"ce-schemaurl": "http://schema.registry/v1",
233-
"Content-Type": "application/json"
232+
[BINARY_HEADERS_03.TYPE]: "type",
233+
[BINARY_HEADERS_03.SPEC_VERSION]: "0.3",
234+
[BINARY_HEADERS_03.SOURCE]: "source",
235+
[BINARY_HEADERS_03.ID]: "id",
236+
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
237+
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
238+
[HEADER_CONTENT_TYPE]: "application/json"
234239
};
235240

236241
var un = new Unmarshaller();
@@ -245,14 +250,14 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
245250
var payload = "eyJtdWNoIjoid293In0=";
246251

247252
var attributes = {
248-
"ce-type": "type",
249-
"ce-specversion": "0.3",
250-
"ce-source": "source",
251-
"ce-id": "id",
252-
"ce-time": "2019-06-16T11:42:00Z",
253-
"ce-schemaurl": "http://schema.registry/v1",
254-
"Content-Type": "application/json",
255-
"ce-datacontentencoding": "binary"
253+
[BINARY_HEADERS_03.TYPE]: "type",
254+
[BINARY_HEADERS_03.SPEC_VERSION]: "0.3",
255+
[BINARY_HEADERS_03.SOURCE]: "source",
256+
[BINARY_HEADERS_03.ID]: "id",
257+
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
258+
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
259+
[HEADER_CONTENT_TYPE]: "application/json",
260+
[BINARY_HEADERS_03.CONTENT_ENCONDING]: "binary"
256261
};
257262

258263
var un = new Unmarshaller();
@@ -273,14 +278,14 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
273278
};
274279

275280
var attributes = {
276-
"ce-type": "type",
277-
"ce-specversion": "0.3",
278-
"ce-source": "source",
279-
"ce-id": "id",
280-
"ce-time": "2019-06-16T11:42:00Z",
281-
"ce-schemaurl": "http://schema.registry/v1",
282-
"Content-Type": "application/json",
283-
"ce-datacontentencoding": "base64"
281+
[BINARY_HEADERS_03.TYPE]: "type",
282+
[BINARY_HEADERS_03.SPEC_VERSION]: "0.3",
283+
[BINARY_HEADERS_03.SOURCE]: "source",
284+
[BINARY_HEADERS_03.ID]: "id",
285+
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
286+
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
287+
[HEADER_CONTENT_TYPE]: "application/json",
288+
[BINARY_HEADERS_03.CONTENT_ENCONDING]: "base64"
284289
};
285290

286291
var un = new Unmarshaller();

0 commit comments

Comments
 (0)