Skip to content

Commit

Permalink
Merge pull request #407 from ilteoood/master
Browse files Browse the repository at this point in the history
BREAKING CHANGE: fastify v5 and node test runner
  • Loading branch information
simoneb authored Dec 9, 2024
2 parents fae2648 + b16ed1e commit 901ac26
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 48 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

19 changes: 0 additions & 19 deletions .eslintrc

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
strategy:
matrix:
node-version:
- 18
- 20
- 22
steps:
Expand All @@ -28,7 +27,7 @@ jobs:
with:
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ vars.AWS_REGION }}
- run: npm run test:ci
- run: npm run test
automerge:
needs: build
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const js = require('@eslint/js')
const prettierRecommended = require('eslint-plugin-prettier/recommended')
const globals = require('globals')

module.exports = [
js.configs.recommended,
prettierRecommended,
{
languageOptions: {
globals: {
...globals.node
},
ecmaVersion: 'latest',
sourceType: 'module'
}
}
]
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AwsClient {
} else {
return Buffer.from(data.SecretBinary, 'base64').toString('utf8')
}
} catch (err) {
} catch {
throw new Error(`Secret not found: ${name}`)
}
}
Expand Down
27 changes: 12 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"lint:staged": "lint-staged",
"test": "tap --reporter=spec --coverage-report=html --coverage-report=text --100 --no-browser test/*.test.js test/**/*.test.js",
"test:ci": "tap --no-color --reporter=spec --coverage-report=json --coverage-report=text --100 test/*.test.js test/**/*.test.js",
"test": "node --test",
"prepare": "husky"
},
"repository": {
Expand All @@ -31,22 +30,20 @@
"node": ">=18"
},
"devDependencies": {
"eslint": "^8.18.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.14.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-standard": "^5.0.0",
"fastify": "^4.0.3",
"husky": "^9.0.11",
"lint-staged": "^15.0.1",
"prettier": "^3.0.1",
"fastify": "^5.1.0",
"husky": "^9.1.7",
"lint-staged": "^15.2.10",
"prettier": "^3.4.2",
"proxyquire": "^2.1.3",
"sinon": "^19.0.2",
"tap": "^16.0.1",
"uuid": "^11.0.2"
"uuid": "^11.0.3"
},
"lint-staged": {
"*.js": [
Expand Down
25 changes: 16 additions & 9 deletions test/client.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const { test, beforeEach } = require('tap')
const { test, beforeEach } = require('node:test')

const sinon = require('sinon')
const proxyquire = require('proxyquire')

Expand Down Expand Up @@ -37,10 +38,13 @@ test('get', (t) => {
SMStub.resolves({ SecretString: 'secret payload' })

const secret = await client.get('secret/name')
t.ok(GSVCStub.call, 'new instance of GetSecretValueCommand')
t.ok(SMStub.called, 'calls send')
t.ok(SMStub.calledWith(sinon.match({ input: { SecretId: 'secret/name' } })), 'provides name as SecretId to send')
t.equal(secret, 'secret payload', 'extracts SecretString')
t.assert.ok(GSVCStub.call, 'new instance of GetSecretValueCommand')
t.assert.ok(SMStub.called, 'calls send')
t.assert.ok(
SMStub.calledWith(sinon.match({ input: { SecretId: 'secret/name' } })),
'provides name as SecretId to send'
)
t.assert.equal(secret, 'secret payload', 'extracts SecretString')
})

t.test('SecretBinary', async (t) => {
Expand All @@ -50,9 +54,12 @@ test('get', (t) => {
SecretBinary: Buffer.from('secret payload').toString('base64')
})
const secret = await client.get('secret/name')
t.ok(SMStub.called, 'calls send')
t.ok(SMStub.calledWith(sinon.match({ input: { SecretId: 'secret/name' } })), 'provides name as SecretId to send')
t.equal(secret, 'secret payload', 'extracts SecretBinary')
t.assert.ok(SMStub.called, 'calls send')
t.assert.ok(
SMStub.calledWith(sinon.match({ input: { SecretId: 'secret/name' } })),
'provides name as SecretId to send'
)
t.assert.equal(secret, 'secret payload', 'extracts SecretBinary')
})

t.test('sdk error', async (t) => {
Expand All @@ -63,6 +70,6 @@ test('get', (t) => {

const promise = client.get('secret/name')

await t.rejects(promise, 'throws error')
await t.assert.rejects(promise, 'throws error')
})
})

0 comments on commit 901ac26

Please sign in to comment.