mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-01-18 16:27:28 +01:00
Add compatibility with Koa v1, fix tests and edit README
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
|
||||
let express = require("express"),
|
||||
supertest = require("supertest"),
|
||||
bundle = require("../");
|
||||
bundle = require("../"),
|
||||
koa = require("koa"),
|
||||
c2k = require("koa-connect"),
|
||||
supertestKoa = require("supertest-koa-agent");
|
||||
|
||||
describe("index", () => {
|
||||
it("metrics returns up=1", done => {
|
||||
@@ -137,4 +140,31 @@ describe("index", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("Koa: metrics returns up=1", done => {
|
||||
const app = koa();
|
||||
const bundled = bundle({
|
||||
prefix: "hello:",
|
||||
whitelist: ["up"]
|
||||
});
|
||||
app.use(c2k(bundled));
|
||||
|
||||
app.use(function*(next) {
|
||||
if (this.path !== "test") {
|
||||
return yield next;
|
||||
}
|
||||
this.body = "it worked";
|
||||
});
|
||||
|
||||
const agent = supertestKoa(app);
|
||||
agent.get("/test").end(() => {
|
||||
agent
|
||||
.get("/metrics")
|
||||
.end((err, res) => {
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.text).toMatch(/hello:up\s1/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user