Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]: feat: add mode option for testing #154

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bin/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports.builder = (yargs) => yargs
type: 'boolean',
conflicts: 'config'
})
.option('mode', {
desc: 'Choose the mode in which the package will be tested',
type: 'string',
choices: ['download', 'pull-request'],
default: 'pull-request'
})
.option('config', {
desc: 'Path to the configuration file. By default it will try to load the configuration from the first file it finds in the current working directory: `.wiby.json`, `.wiby.js`',
type: 'string'
Expand All @@ -24,7 +30,7 @@ exports.builder = (yargs) => yargs
exports.handler = (params) => {
const config = params.dependent
? {
dependents: [{ repository: params.dependent, pullRequest: !!params['pull-request'] }]
dependents: [{ repository: params.dependent, pullRequest: !!params['pull-request'], mode: params.mode || 'pull-request' }]
}
: wiby.validate({ config: params.config })

Expand Down
3 changes: 2 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const dependentSchema = joi.object({
'git+https'
]
}),
pullRequest: joi.boolean().optional()
pullRequest: joi.boolean().optional(),
mode: joi.string().valid('pull-request', 'download').optional().default('pull-request')
}).unknown(false)

exports.schema = joi.object({
Expand Down
9 changes: 6 additions & 3 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ tap.test('config validation', async (tap) => {
dependents: [
{
repository: 'https://github.com/wiby-test/partial',
pullRequest: false
pullRequest: false,
mode: "pull-request"
},
{
repository: 'git://github.com/wiby-test/fail',
pullRequest: false
pullRequest: false,
mode: "pull-request"
},
{
repository: 'git+https://github.com/wiby-test/pass',
pullRequest: true
pullRequest: true,
mode: "pull-request"
}
]
})
Expand Down
Loading