Fix unhandled promise rejection in create monitor
If a monitor was created with an argument that was not a key-value type, a promise would be rejected outside of the main maxctrl function. Added a test case that covers this and fixed a few other test coverage problems that were present.
This commit is contained in:
@ -159,12 +159,10 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
}
|
||||
|
||||
if (argv.params) {
|
||||
var err = validateParams(argv, argv.params)
|
||||
if (err) {
|
||||
return Promise.reject(err)
|
||||
}
|
||||
var err = false;
|
||||
|
||||
if (argv.params) {
|
||||
err = validateParams(argv, argv.params)
|
||||
monitor.data.attributes.parameters = argv.params.reduce(to_obj, {})
|
||||
}
|
||||
|
||||
@ -182,6 +180,9 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
|
||||
maxctrl(argv, function(host) {
|
||||
if (err) {
|
||||
return Promise.reject(err)
|
||||
}
|
||||
return doRequest(host, 'monitors', null, {method: 'POST', body: monitor})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user