upgrade joi scheme validator to 17.4.2

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2021-08-16 19:18:40 +02:00
parent a0090325eb
commit 9eca415212
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
3 changed files with 33 additions and 54 deletions

View File

@ -8,7 +8,7 @@
"@octokit/rest": "^18.9.1",
"await-lock": "^1.2.1",
"handlebars": "^4.7.7",
"joi": "^14.3.0",
"joi": "^17.4.2",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"koa-joi-router": "^8.0.0",

View File

@ -14,55 +14,67 @@ describe('Schema', () => {
})
describe('id', () => {
it('can be a string', async () => {
let rval = await Joi.validate(build, schema)
expect(rval).to.eql(build)
it('can be a string', () => {
let rval = schema.validate(build)
expect(rval.value).to.eql(build)
})
it('can be a number', async () => {
it('can be a number', () => {
build.id = 123
let rval = await Joi.validate(build, schema)
expect(rval).to.eql(build)
let rval = schema.validate(build)
expect(rval.value).to.eql(build)
})
it('can\'t be null', () => {
build.id = null
expect(Joi.validate(build, schema)).rejectedWith('"id" must be a number, "id" must be a string')
let rval = schema.validate(build)
expect(rval.error.message).to.eq(
'"id" must be one of [number, string]'
)
})
})
describe('commit', () => {
it('has to be a commit', async () => {
let rval = await Joi.validate(build, schema)
expect(rval).to.eql(build)
it('has to be a commit', () => {
let rval = schema.validate(build)
expect(rval.value).to.eql(build)
})
it('can\'t be a null', () => {
build.commit = null
expect(Joi.validate(build, schema)).rejectedWith('"commit" must be a string')
let rval = schema.validate(build)
expect(rval.error.message).to.eq(
'"commit" must be a string'
)
})
it('can\'t be a number', () => {
build.commit = 1
expect(Joi.validate(build, schema)).rejectedWith('"commit" must be a string')
let rval = schema.validate(build)
expect(rval.error.message).to.eq(
'"commit" must be a string'
)
})
})
describe('pkg_url', () => {
it('has to be a URL', async () => {
let rval = await Joi.validate(build, schema)
expect(rval).to.eql(build)
it('has to be a URL', () => {
let rval = schema.validate(build)
expect(rval.value).to.eql(build)
})
it('can be a null', async () => {
it('can be a null', () => {
build.pkg_url = null
let rval = await Joi.validate(build, schema)
expect(rval).to.eql(build)
let rval = schema.validate(build)
expect(rval.value).to.eql(build)
})
it('can\'t be a number', () => {
build.pkg_url = 1
expect(Joi.validate(build, schema)).rejectedWith('"pkg_url" must be a string')
let rval = schema.validate(build)
expect(rval.error.message).to.eq(
'"pkg_url" must be a string'
)
})
})
})

View File

@ -2401,11 +2401,6 @@ he@1.2.0:
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
hoek@6.x.x:
version "6.1.3"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-6.1.3.tgz#73b7d33952e01fe27a38b0457294b79dd8da242c"
integrity sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==
homedir-polyfill@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8"
@ -2853,13 +2848,6 @@ isarray@1.0.0, isarray@~1.0.0:
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
isemail@3.x.x:
version "3.2.0"
resolved "https://registry.yarnpkg.com/isemail/-/isemail-3.2.0.tgz#59310a021931a9fb06bbb51e155ce0b3f236832c"
integrity sha512-zKqkK+O+dGqevc93KNsbZ/TqTUFd46MwWjYOoMrjIMZ51eU7DtQG3Wmd9SQQT7i7RVnuTPEiYEWHU3MSbxC1Tg==
dependencies:
punycode "2.x.x"
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
@ -2938,16 +2926,7 @@ istanbul-reports@^3.0.2:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"
joi@^14.3.0:
version "14.3.1"
resolved "https://registry.yarnpkg.com/joi/-/joi-14.3.1.tgz#164a262ec0b855466e0c35eea2a885ae8b6c703c"
integrity sha512-LQDdM+pkOrpAn4Lp+neNIFV3axv1Vna3j38bisbQhETPMANYRbFJFUyOZcOClYvM/hppMhGWuKSFEK9vjrB+bQ==
dependencies:
hoek "6.x.x"
isemail "3.x.x"
topo "3.x.x"
joi@^17.2.1:
joi@^17.2.1, joi@^17.4.2:
version "17.4.2"
resolved "https://registry.yarnpkg.com/joi/-/joi-17.4.2.tgz#02f4eb5cf88e515e614830239379dcbbe28ce7f7"
integrity sha512-Lm56PP+n0+Z2A2rfRvsfWVDXGEWjXxatPopkQ8qQ5mxCEhwHG+Ettgg5o98FFaxilOxozoa14cFhrE/hOzh/Nw==
@ -4149,11 +4128,6 @@ pumpify@^1.3.5:
inherits "^2.0.3"
pump "^2.0.0"
punycode@2.x.x:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
pupa@^2.0.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.1.1.tgz#f5e8fd4afc2c5d97828faa523549ed8744a20d62"
@ -5033,13 +5007,6 @@ toidentifier@1.0.0:
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
topo@3.x.x:
version "3.0.3"
resolved "https://registry.yarnpkg.com/topo/-/topo-3.0.3.tgz#d5a67fb2e69307ebeeb08402ec2a2a6f5f7ad95c"
integrity sha512-IgpPtvD4kjrJ7CRA3ov2FhWQADwv+Tdqbsf1ZnPUSAtCJ9e1Z44MmoSGDXGk4IppoZA7jd/QRkNddlLJWlUZsQ==
dependencies:
hoek "6.x.x"
touch@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/touch/-/touch-3.1.0.tgz#fe365f5f75ec9ed4e56825e0bb76d24ab74af83b"