Skip to content

Commit

Permalink
fix: amend error codes for latest avvio v8.3.0 (#5309)
Browse files Browse the repository at this point in the history
* Fix tests for latest avvio

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* fixup

Signed-off-by: Matteo Collina <hello@matteocollina.com>

---------

Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina committed Feb 9, 2024
1 parent 42cf27c commit f26de5d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/errors.js
Expand Up @@ -464,5 +464,6 @@ module.exports.AVVIO_ERRORS_MAP = {
AVV_ERR_PLUGIN_NOT_VALID: codes.FST_ERR_PLUGIN_NOT_VALID,
AVV_ERR_ROOT_PLG_BOOTED: codes.FST_ERR_ROOT_PLG_BOOTED,
AVV_ERR_PARENT_PLG_LOADED: codes.FST_ERR_PARENT_PLUGIN_BOOTED,
AVV_ERR_READY_TIMEOUT: codes.FST_ERR_PLUGIN_TIMEOUT
AVV_ERR_READY_TIMEOUT: codes.FST_ERR_PLUGIN_TIMEOUT,
AVV_ERR_PLUGIN_EXEC_TIMEOUT: codes.FST_ERR_PLUGIN_TIMEOUT
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -204,7 +204,7 @@
"@fastify/error": "^3.4.0",
"@fastify/fast-json-stringify-compiler": "^4.3.0",
"abstract-logging": "^2.0.1",
"avvio": "^8.2.1",
"avvio": "^8.3.0",
"fast-content-type-parse": "^1.1.0",
"fast-json-stringify": "^5.8.0",
"find-my-way": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test/hooks.on-ready.test.js
Expand Up @@ -295,7 +295,7 @@ t.test('onReady cannot add lifecycle hooks', t => {
t.ok(error)
t.equal(error.message, 'Root plugin has already booted')
// TODO: look where the error pops up
t.equal(error.code, 'AVV_ERR_PLUGIN_NOT_VALID')
t.equal(error.code, 'AVV_ERR_ROOT_PLG_BOOTED')
done(error)
}
})
Expand Down
6 changes: 3 additions & 3 deletions test/plugin.4.test.js
Expand Up @@ -22,7 +22,7 @@ test('pluginTimeout', t => {
"fastify-plugin: Plugin did not start in time: 'function (app, opts, done) { -- // to no call done on purpose'. You may have forgotten to call 'done' function or to resolve a Promise")
t.equal(err.code, 'FST_ERR_PLUGIN_TIMEOUT')
t.ok(err.cause)
t.equal(err.cause.code, 'AVV_ERR_READY_TIMEOUT')
t.equal(err.cause.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
})
})

Expand All @@ -40,7 +40,7 @@ test('pluginTimeout - named function', t => {
"fastify-plugin: Plugin did not start in time: 'nameFunction'. You may have forgotten to call 'done' function or to resolve a Promise")
t.equal(err.code, 'FST_ERR_PLUGIN_TIMEOUT')
t.ok(err.cause)
t.equal(err.cause.code, 'AVV_ERR_READY_TIMEOUT')
t.equal(err.cause.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
})
})

Expand All @@ -60,7 +60,7 @@ test('pluginTimeout default', t => {
"fastify-plugin: Plugin did not start in time: 'function (app, opts, done) { -- // default time elapsed without calling done'. You may have forgotten to call 'done' function or to resolve a Promise")
t.equal(err.code, 'FST_ERR_PLUGIN_TIMEOUT')
t.ok(err.cause)
t.equal(err.cause.code, 'AVV_ERR_READY_TIMEOUT')
t.equal(err.cause.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
})

t.teardown(clock.uninstall)
Expand Down
2 changes: 1 addition & 1 deletion test/pretty-print.test.js
Expand Up @@ -220,7 +220,7 @@ test('pretty print - empty plugins', t => {
fastify.ready(() => {
const tree = fastify.printPlugins()
t.equal(typeof tree, 'string')
t.match(tree, 'bound root')
t.match(tree, /root \d+ ms\n└── bound _after \d+ ms/m)
})
})

Expand Down

0 comments on commit f26de5d

Please sign in to comment.