Skip to content

Commit

Permalink
add healthz tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed May 9, 2024
1 parent 514ae15 commit dcf727a
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import protectedNock from './test-fixtures/nocks/protected_status_signing.js'
import unprotectedStatusUpdateNock from './test-fixtures/nocks/unprotected_status_update.js'
import unknownStatusIdNock from './test-fixtures/nocks/unknown_status_id_nock.js'
import protectedStatusUpdateNock from './test-fixtures/nocks/protected_status_update.js'

import healthzStatusSigningNock from './test-fixtures/nocks/healthz_status_signing.js'
import { build } from './app.js'

let testTenantToken
Expand Down Expand Up @@ -228,4 +228,34 @@ describe('api', () => {
expect(response.status).to.eql(200)
})
})

describe('/healthz', () => {
it('returns 200 when healthy', async () => {
healthzStatusSigningNock()
await request(app)
.get(`/healthz`)

Check failure on line 236 in src/app.test.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Strings must use singlequote
.expect('Content-Type', /json/)
.expect((res) => {
expect(res.body.message).to.contain('ok')
})
.expect(200)
})
})

describe('/healthz fail', () => {
// to force an error with the health check, we
// simply don't set the nock for the signing and

Check failure on line 247 in src/app.test.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Trailing spaces not allowed
// status services

it('returns 503 when not healthy', async () => {
await request(app)
.get(`/healthz`)

Check failure on line 252 in src/app.test.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Strings must use singlequote
.expect('Content-Type', /json/)
.expect((res) => {
expect(res.body.error).to.contain('error')
})
.expect(503)
})
})

Check failure on line 259 in src/app.test.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Block must not be padded by blank lines

})
86 changes: 86 additions & 0 deletions src/test-fixtures/nocks/healthz_status_signing.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dcf727a

Please sign in to comment.