Skip to content

Commit a8b705d

Browse files
committed
commit before pull from Jonathan's branch
1 parent 13f96b1 commit a8b705d

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

__tests__/integrationtests.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,28 @@ describe('--Integration Tests--', () => {
3232
expect(streamExists).toEqual(true);
3333
})
3434

35-
it('.push properly creates a push query', () => {
35+
it('.push properly creates a push query', async () => {
3636
let pushActive = false;
37-
client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;', async (data) => {
37+
await client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;', async (data) => {
3838
if (JSON.parse(data).queryId) {
3939
pushActive = true;
4040
}
4141
expect(pushActive).toEqual(true)
4242
});
4343
})
4444

45-
it('.terminate properly terminates a push query', () => {
46-
client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 3;', async (data) => {
47-
const terminateRes = await client.terminate(JSON.parse(data).queryId);
45+
it('.terminate properly terminates a push query', async () => {
46+
let terminateRes;
47+
await client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 3;', async (data) => {
48+
terminateRes = await client.terminate(JSON.parse(data).queryId);
4849
expect(terminateRes.wasTerminated).toEqual(true);
4950
})
51+
// console.log("this is terminate", terminateRes);
52+
// const queriesList = await client.ksql("LIST QUERIES;");
53+
// console.log(queriesList);
54+
// const queryIdDelete = (queriesList.queries[0]).id;
55+
// const response = await client.terminate(queryIdDelete);
56+
// console.log(response);
5057
})
5158

5259
it('.insertStream properly inserts a row into a stream', async () => {
@@ -65,7 +72,6 @@ describe('--Integration Tests--', () => {
6572

6673
it('.pull receives the correct data from a pull query', async () => {
6774
const pullData = await client.pull("SELECT * FROM TESTJESTSTREAM;");
68-
console.log(pullData[1]);
6975
expect(pullData[1]).toEqual(["stab-rabbit", "123@mail.com", 100]);
7076
})
7177

ksqljs/ksqlJS.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,47 @@ class ksqljs {
150150
console.error(error);
151151
throw new ksqlDBError(error);
152152
});
153+
// return new Promise((resolve, reject) => {
154+
// const session = http2.connect(
155+
// this.ksqldbURL,
156+
// this.httpsAgentHttp2 ? this.httpsAgentHttp2 : {}
157+
// );
158+
159+
// session.on("error", (err) => reject(err));
160+
161+
// const req = session.request(
162+
// this.secret && this.API ?
163+
// {
164+
// ":path": "/ksql",
165+
// ":method": "POST",
166+
// "Authorization": this.API && this.secret ? `Basic ${Buffer.from(this.API + ":" + this.secret, 'utf8').toString('base64')}` : '',
167+
// }
168+
// :
169+
// {
170+
// ":path": "/ksql",
171+
// ":method": "POST",
172+
// }
173+
// );
174+
175+
// const query = builder.build("TERMINATE ?;", queryId);
176+
177+
// const reqBody = {
178+
// sql: query,
179+
// Accept: "application/json, application/vnd.ksqlapi.delimited.v1",
180+
// };
181+
182+
// req.write(JSON.stringify(reqBody), "utf8");
183+
// req.end();
184+
// req.setEncoding("utf8");
185+
186+
// req.on("data", (data) => {
187+
// console.log("Here's the response", data);
188+
// resolve();
189+
// });
190+
191+
// req.on("end", () => {
192+
// session.close()});
193+
// })
153194
}
154195

155196
/**

0 commit comments

Comments
 (0)