Skip to content

Commit

Permalink
test: use header constants in unmarshaller tests (#60)
Browse files Browse the repository at this point in the history
This commit updates the http unmarshaller tests to use the constants
available in lib/bindings/http/constants.js.

Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
  • Loading branch information
danbev authored Apr 29, 2020
1 parent 5110ad4 commit e087805
Showing 1 changed file with 41 additions and 36 deletions.
77 changes: 41 additions & 36 deletions test/bindings/http/unmarshaller_0_3_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const source = "urn:event:from:myapi/resourse/123";
const now = new Date();
const schemaurl = "http://cloudevents.io/schema.json";
const subject = "subject.ext";
const {
BINARY_HEADERS_03,
HEADER_CONTENT_TYPE
} = require("../../../lib/bindings/http/constants.js");

const ceContentType = "application/json";

const data = {
Expand Down Expand Up @@ -176,13 +181,13 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
data: "dataString"
};
var attributes = {
"ce-type": "type",
"ce-specversion": "0.3",
"ce-source": "source",
"ce-id": "id",
"ce-time": "2019-06-16T11:42:00Z",
"ce-schemaurl": "http://schema.registry/v1",
"Content-Type": "text/html"
[BINARY_HEADERS_03.TYPE]: "type",
[BINARY_HEADERS_03.SPEC_VERSION]: "0.3",
[BINARY_HEADERS_03.SOURCE]: "source",
[BINARY_HEADERS_03.ID]: "id",
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
[HEADER_CONTENT_TYPE]: "text/html"
};

var un = new Unmarshaller();
Expand All @@ -200,13 +205,13 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
data: "dataString"
};
var attributes = {
"ce-type": "type",
[BINARY_HEADERS_03.TYPE]: "type",
"CE-CloudEventsVersion": "0.1",
"ce-source": "source",
"ce-id": "id",
"ce-time": "2019-06-16T11:42:00Z",
"ce-schemaurl": "http://schema.registry/v1",
"Content-Type": "application/json"
[BINARY_HEADERS_03.SOURCE]: "source",
[BINARY_HEADERS_03.ID]: "id",
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
[HEADER_CONTENT_TYPE]: "application/json"
};

var un = new Unmarshaller();
Expand All @@ -224,13 +229,13 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => {
data: "dataString"
};
var attributes = {
"ce-type": "type",
"ce-specversion": "0.3",
"ce-source": "source",
"ce-id": "id",
"ce-time": "2019-06-16T11:42:00Z",
"ce-schemaurl": "http://schema.registry/v1",
"Content-Type": "application/json"
[BINARY_HEADERS_03.TYPE]: "type",
[BINARY_HEADERS_03.SPEC_VERSION]: "0.3",
[BINARY_HEADERS_03.SOURCE]: "source",
[BINARY_HEADERS_03.ID]: "id",
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
[HEADER_CONTENT_TYPE]: "application/json"
};

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

var attributes = {
"ce-type": "type",
"ce-specversion": "0.3",
"ce-source": "source",
"ce-id": "id",
"ce-time": "2019-06-16T11:42:00Z",
"ce-schemaurl": "http://schema.registry/v1",
"Content-Type": "application/json",
"ce-datacontentencoding": "binary"
[BINARY_HEADERS_03.TYPE]: "type",
[BINARY_HEADERS_03.SPEC_VERSION]: "0.3",
[BINARY_HEADERS_03.SOURCE]: "source",
[BINARY_HEADERS_03.ID]: "id",
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
[HEADER_CONTENT_TYPE]: "application/json",
[BINARY_HEADERS_03.CONTENT_ENCONDING]: "binary"
};

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

var attributes = {
"ce-type": "type",
"ce-specversion": "0.3",
"ce-source": "source",
"ce-id": "id",
"ce-time": "2019-06-16T11:42:00Z",
"ce-schemaurl": "http://schema.registry/v1",
"Content-Type": "application/json",
"ce-datacontentencoding": "base64"
[BINARY_HEADERS_03.TYPE]: "type",
[BINARY_HEADERS_03.SPEC_VERSION]: "0.3",
[BINARY_HEADERS_03.SOURCE]: "source",
[BINARY_HEADERS_03.ID]: "id",
[BINARY_HEADERS_03.TIME]: "2019-06-16T11:42:00Z",
[BINARY_HEADERS_03.SCHEMA_URL]: "http://schema.registry/v1",
[HEADER_CONTENT_TYPE]: "application/json",
[BINARY_HEADERS_03.CONTENT_ENCONDING]: "base64"
};

var un = new Unmarshaller();
Expand Down

0 comments on commit e087805

Please sign in to comment.