Skip to content

Commit

Permalink
Merge next into master (#241)
Browse files Browse the repository at this point in the history
* update for Fastify v5 (#236)

* update for v5

* add pre commit

* upgrade for fastify 5 (#238)

Signed-off-by: Cristian Barlutiu <[email protected]>

* update for Fastify v5 (#236)

* update for v5

* add pre commit

* upgrade for fastify 5 (#238)

Signed-off-by: Cristian Barlutiu <[email protected]>

* update deps and tests

---------

Signed-off-by: Cristian Barlutiu <[email protected]>
Co-authored-by: Gürgün Dayıoğlu <[email protected]>
Co-authored-by: Cristian Barlutiu <[email protected]>
  • Loading branch information
3 people authored Jun 23, 2024
1 parent 026d538 commit 1a5a200
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.1.0
with:
lint: true
license-check: true
7 changes: 2 additions & 5 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
ts: false
jsx: false
flow: false
coverage: true

files:
- test/**/*.js
plugin:
- "!@tapjs/typescript"
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
},
"homepage": "https://github.com/fastify/fastify-plugin#readme",
"devDependencies": {
"@fastify/type-provider-typebox": "^4.0.0",
"@types/node": "^20.1.0",
"fastify": "^4.0.1",
"@fastify/pre-commit": "^2.1.0",
"@fastify/type-provider-typebox": "^5.0.0-pre.fv5.1",
"@types/node": "^20.11.20",
"fastify": "^5.0.0-alpha.2",
"proxyquire": "^2.1.3",
"standard": "^17.0.0",
"tap": "^16.0.1",
"standard": "^17.1.0",
"tap": "^18.7.0",
"tsd": "^0.31.0"
}
}
56 changes: 31 additions & 25 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const test = t.test
const fp = require('../plugin')
const Fastify = require('fastify')

const pkg = require('../package.json')

test('fastify-plugin is a function', t => {
t.plan(1)
t.type(fp, 'function')
Expand Down Expand Up @@ -206,12 +208,12 @@ test('should check fastify dependency graph - plugin', t => {
const fastify = Fastify()

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '4.x',
fastify: '5.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '4.x',
fastify: '5.x',
name: 'test',
dependencies: ['plugin1-name', 'plugin2-name']
}))
Expand All @@ -226,12 +228,12 @@ test('should check fastify dependency graph - decorate', t => {
const fastify = Fastify()

fastify.decorate('plugin1', fp((fastify, opts, next) => next(), {
fastify: '4.x',
fastify: '5.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '4.x',
fastify: '5.x',
name: 'test',
decorators: { fastify: ['plugin1', 'plugin2'] }
}))
Expand All @@ -246,12 +248,12 @@ test('should check fastify dependency graph - decorateReply', t => {
const fastify = Fastify()

fastify.decorateReply('plugin1', fp((fastify, opts, next) => next(), {
fastify: '4.x',
fastify: '5.x',
name: 'plugin1-name'
}))

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '4.x',
fastify: '5.x',
name: 'test',
decorators: { reply: ['plugin1', 'plugin2'] }
}))
Expand Down Expand Up @@ -311,20 +313,24 @@ test('should check dependencies when encapsulated', t => {
})
})

test('should check version when encapsulated', t => {
t.plan(1)
const fastify = Fastify()
test(
'should check version when encapsulated',
{ skip: /\d-.+/.test(pkg.devDependencies.fastify) },
t => {
t.plan(1)
const fastify = Fastify()

fastify.register(fp((fastify, opts, next) => next(), {
name: 'test',
fastify: '<=2.10.0',
encapsulate: true
}))
fastify.register(fp((fastify, opts, next) => next(), {
name: 'test',
fastify: '<=2.10.0',
encapsulate: true
}))

fastify.ready(err => {
t.match(err.message, /fastify-plugin: test - expected '<=2.10.0' fastify version, '\d.\d+.\d+' is installed/)
})
})
fastify.ready(err => {
t.match(err.message, /fastify-plugin: test - expected '<=2.10.0' fastify version, '\d.\d+.\d+' is installed/)
})
}
)

test('should check decorators when encapsulated', t => {
t.plan(1)
Expand All @@ -333,7 +339,7 @@ test('should check decorators when encapsulated', t => {
fastify.decorate('plugin1', 'foo')

fastify.register(fp((fastify, opts, next) => next(), {
fastify: '4.x',
fastify: '5.x',
name: 'test',
encapsulate: true,
decorators: { fastify: ['plugin1', 'plugin2'] }
Expand All @@ -352,14 +358,14 @@ test('plugin name when encapsulated', async t => {
})

fastify.register(fp(getFn('hello'), {
fastify: '4.x',
fastify: '5.x',
name: 'hello',
encapsulate: true
}))

fastify.register(function plugin (fastify, opts, next) {
fastify.register(fp(getFn('deep'), {
fastify: '4.x',
fastify: '5.x',
name: 'deep',
encapsulate: true
}))
Expand All @@ -368,25 +374,25 @@ test('plugin name when encapsulated', async t => {
t.equal(fastify.pluginName, 'deep-deep', 'should be deep-deep')

fastify.register(fp(getFn('deep-deep-deep'), {
fastify: '4.x',
fastify: '5.x',
name: 'deep-deep-deep',
encapsulate: true
}))

fastify.register(fp(getFn('deep-deep -> not-encapsulated-2'), {
fastify: '4.x',
fastify: '5.x',
name: 'not-encapsulated-2'
}))

next()
}, {
fastify: '4.x',
fastify: '5.x',
name: 'deep-deep',
encapsulate: true
}))

fastify.register(fp(getFn('plugin -> not-encapsulated'), {
fastify: '4.x',
fastify: '5.x',
name: 'not-encapsulated'
}))

Expand Down

0 comments on commit 1a5a200

Please sign in to comment.