Skip to content

Commit 44ca402

Browse files
committed
More tests
1 parent c92c934 commit 44ca402

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

test/unit-test/metric-middleware-koa-test.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ describe('metrics-middleware', () => {
788788
Prometheus.register.clear();
789789
});
790790
});
791-
describe('when excludeDefaultMetricLabels is passed', () => {
791+
describe('when calling the function with excludeDefaultMetricLabels option', () => {
792792
it('or it\'s undefined', () => {
793793
middleware();
794794
expect(Prometheus.register.getSingleMetric('http_request_size_bytes').labelNames).to.have.members(['method', 'route', 'code']);
@@ -822,5 +822,43 @@ describe('metrics-middleware', () => {
822822
Prometheus.register.clear();
823823
});
824824
});
825+
describe('when calling the function with useCountersForRequestSizeMetric option', () => {
826+
before(() => {
827+
middleware({
828+
useCountersForRequestSizeMetric: true
829+
});
830+
});
831+
it('shouldn\'t have http_request_size_bytes metric', () => {
832+
expect(Prometheus.register.getSingleMetric('http_request_size_bytes')).to.equal(undefined);
833+
});
834+
it('should have http_request_size_bytes_sum with the right labels', () => {
835+
expect(Prometheus.register.getSingleMetric('http_request_size_bytes_sum').labelNames).to.have.members(['method', 'route', 'code']);
836+
});
837+
it('should have http_request_size_bytes_count with the right labels', () => {
838+
expect(Prometheus.register.getSingleMetric('http_request_size_bytes_count').labelNames).to.have.members(['method', 'route', 'code']);
839+
});
840+
after(() => {
841+
Prometheus.register.clear();
842+
});
843+
});
844+
describe('when calling the function with useCountersForResponseSizeMetric option', () => {
845+
before(() => {
846+
middleware({
847+
useCountersForResponseSizeMetric: true
848+
});
849+
});
850+
it('shouldn\'t have http_response_size_bytes metric', () => {
851+
expect(Prometheus.register.getSingleMetric('http_response_size_bytes')).to.equal(undefined);
852+
});
853+
it('should have http_response_size_bytes_sum with the right labels', () => {
854+
expect(Prometheus.register.getSingleMetric('http_response_size_bytes_sum').labelNames).to.have.members(['method', 'route', 'code']);
855+
});
856+
it('should have http_response_size_bytes_count with the right labels', () => {
857+
expect(Prometheus.register.getSingleMetric('http_response_size_bytes_count').labelNames).to.have.members(['method', 'route', 'code']);
858+
});
859+
after(() => {
860+
Prometheus.register.clear();
861+
});
862+
});
825863
});
826864
});

0 commit comments

Comments
 (0)