diff --git a/src/events.test.ts b/src/events.test.ts index 0287025..2c86cbd 100644 --- a/src/events.test.ts +++ b/src/events.test.ts @@ -9,14 +9,35 @@ const twoHourAgo = dateFns.format( "yyyy-MM-dd hh:mm:ss" ); +const now = dateFns.format(new Date(), "yyyy-MM-dd hh:mm:ss"); + describe("Events", () => { + test.only("clickhouse is healthy", async () => { + const { data } = await ( + await clickhouseClient.query({ + query: ` + SELECT + hostName() AS host, + uptime() AS uptime_seconds, + version() AS clickhouse_version, + 'OK' AS status + FROM system.tables + LIMIT 1; + `, + }) + ).json(); + const [{ status }] = data as any; + assert.equal(status, "OK"); + }); test("has inserted events", async () => { + const query = knex("events") + .count("") + .whereBetween("created_at", [twoHourAgo, now]) + .toString(); + console.log(query); const { data } = (await ( await clickhouseClient.query({ - query: knex("events") - .count("") - .where("created_at", ">", twoHourAgo) - .toString(), + query, }) ).json()) as any; assert.notEqual(Number.parseInt(data[0]["count()"], 10), 0);