From eeb2db4e3b619b3110e5aca4062adf2b0bb5e3ae Mon Sep 17 00:00:00 2001 From: Dino Lozina Date: Mon, 27 Feb 2023 09:39:48 +0100 Subject: [PATCH 1/2] Fixed issue stream publish method fails --- src/connection.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/connection.ts b/src/connection.ts index 03ee9fe..052ebfa 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -365,7 +365,8 @@ export class Connection { } else { body = String(body); } - } else if ((path && path.includes("/streams")) === true) { + } + if ((path && path.includes("/streams")) === true) { contentType = "application/json"; } From 6eb483684b3585e643c6509892647cbf8d4a9c0f Mon Sep 17 00:00:00 2001 From: Dino Lozina Date: Mon, 27 Feb 2023 10:37:53 +0100 Subject: [PATCH 2/2] Fixed issue stream publish method fails --- src/test/28-manipulating-streams.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/test/28-manipulating-streams.ts b/src/test/28-manipulating-streams.ts index a4a4c55..32713e2 100644 --- a/src/test/28-manipulating-streams.ts +++ b/src/test/28-manipulating-streams.ts @@ -3,8 +3,6 @@ import { C8Client } from "../jsC8"; import { Stream } from "../stream"; import * as dotenv from "dotenv"; -// TODO : @VIKAS Update Test cases - describe("Manipulating streams", function () { dotenv.config(); // create fabric takes 11s in a standard cluster @@ -194,6 +192,22 @@ describe("Manipulating streams", function () { // }); // }); + describe("publish message to stream", async () => { + it("publishes message to stream", async () => { + const name = `stream${Date.now()}`; + stream = client.stream(name, false); + const response = await stream.createStream(); + expect(response.error).to.be.false; + const messageResponse = await stream.publishMessage( + "Hello Macrometa stream!" + ); + expect(messageResponse.code).to.equal(202); + expect(messageResponse.error).to.be.false; + const deleteStreamResponse = await stream.deleteStream(); + expect(deleteStreamResponse.error).to.be.false; + }); + }); + describe("stream.websocket", function () { let dcName: string; let consumer: any;