Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from digicatapult/chore/template-content-updates
Browse files Browse the repository at this point in the history
helper and test updates
  • Loading branch information
darrylmorton-digicatapult authored Jan 11, 2022
2 parents 8a4eef4 + a0db2a2 commit 446ad19
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 41 deletions.
4 changes: 2 additions & 2 deletions helm/vitalam-service-template/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
name: vitalam-service-template
appVersion: '0.0.1'
appVersion: '0.0.2'
description: A Helm chart for vitalam-service-template
version: '0.0.1'
version: '0.0.2'
type: application
maintainers:
- name: digicatapult
Expand Down
2 changes: 1 addition & 1 deletion helm/vitalam-service-template/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ config:
image:
repository: ghcr.io/digicatapult/vitalam-service-template
pullPolicy: IfNotPresent
tag: 'v0.0.1'
tag: 'v0.0.2'
pullSecrets: ['ghcr-digicatapult']
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digicatapult/vitalam-service-template",
"version": "0.0.1",
"version": "0.0.2",
"description": "Service for VITALam",
"main": "app/index.js",
"scripts": {
Expand Down
37 changes: 37 additions & 0 deletions test/helper/routeHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint no-console: "off" */
const request = require('supertest')

const { API_MAJOR_VERSION } = require('../../app/env')

async function apiDocs({ app }) {
return request(app)
.get(`/${API_MAJOR_VERSION}/api-docs`)
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
.then((response) => {
return response
})
.catch((err) => {
console.error(`healthCheckErr ${err}`)
return err
})
}

async function healthCheck({ app }) {
return request(app)
.get('/health')
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
.then((response) => {
return response
})
.catch((err) => {
console.error(`healthCheckErr ${err}`)
return err
})
}

module.exports = {
apiDocs,
healthCheck,
}
13 changes: 0 additions & 13 deletions test/helpers/server.js

This file was deleted.

22 changes: 10 additions & 12 deletions test/integration/docs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ const { describe, before, it } = require('mocha')
const jsonChai = require('chai-json')
const { expect } = require('chai').use(jsonChai)

const { setupServer } = require('../helpers/server')
const { API_MAJOR_VERSION } = require('../../app/env')
const { createHttpServer } = require('../../app/server')
const { apiDocs } = require('../helper/routeHelper')

describe('api-docs', function () {
const context = {}
let app

before(async function () {
await setupServer(context)
context.response = await context.request.get(`/${API_MAJOR_VERSION}/api-docs`)
app = await createHttpServer()
})

it('should return 200', function () {
expect(context.response.status).to.equal(200)
})
it('should return 200', async function () {
const actualResult = await apiDocs(app)

it('successfully returns the api docs json', function () {
expect(context.response.body).to.be.a.jsonObj()
expect(JSON.stringify(context.response.body)).to.include('openapi')
expect(JSON.stringify(context.response.body)).to.include('info')
expect(actualResult.status).to.equal(200)
expect(actualResult.body).to.be.a.jsonObj()
expect(JSON.stringify(actualResult.body)).to.include('openapi')
expect(JSON.stringify(actualResult.body)).to.include('info')
})
})
20 changes: 10 additions & 10 deletions test/integration/httpServer.test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const { describe, before, it } = require('mocha')
const { describe, before, test } = require('mocha')
const { expect } = require('chai')

const { setupServer } = require('../helpers/server')
const { createHttpServer } = require('../../app/server')
const { API_VERSION } = require('../../app/env')
const { healthCheck } = require('../helper/routeHelper')

describe('health', function () {
const context = {}
let app

before(async function () {
await setupServer(context)
context.response = await context.request.get('/health')
app = await createHttpServer()
})

it('should return 200', function () {
expect(context.response.status).to.equal(200)
})
test('health check', async function () {
const expectedResult = { status: 'ok', version: API_VERSION }

it('should return success', function () {
expect(context.response.body).to.deep.equal({ version: API_VERSION, status: 'ok' })
const actualResult = await healthCheck(app)
expect(actualResult.status).to.equal(200)
expect(actualResult.body).to.deep.equal(expectedResult)
})
})

0 comments on commit 446ad19

Please sign in to comment.