forked from external-secrets/kubernetes-external-secrets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.test.js
34 lines (28 loc) · 895 Bytes
/
metrics.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* eslint-env mocha */
'use strict'
const { expect } = require('chai')
const sinon = require('sinon')
const Prometheus = require('prom-client')
const Metrics = require('./metrics')
describe('Metrics', () => {
let registry
let metrics
beforeEach(async () => {
registry = new Prometheus.Registry()
metrics = new Metrics({ registry })
})
afterEach(async () => {
sinon.restore()
})
it('should store metrics', async () => {
metrics.observeSync({
name: 'foo',
namespace: 'example',
backend: 'foo',
status: 'success'
})
expect(registry.metrics()).to.have.string('kubernetes_external_secrets_sync_calls_count{name="foo",namespace="example",backend="foo",status="success"} 1')
// Deprecated metric.
expect(registry.metrics()).to.have.string('sync_calls{name="foo",namespace="example",backend="foo",status="success"} 1')
})
})