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:
Markus Mäkelä
2019-04-17 00:00:24 +03:00
parent cba23781e0
commit 163b3a2da5
4 changed files with 30 additions and 6 deletions

View File

@ -18,6 +18,18 @@ describe("Create/Destroy Commands", function() {
.should.be.rejected
})
it('monitor without parameters fails due to missing user parameter', function() {
return verifyCommand('create monitor my-monitor mysqlmon', 'monitors/my-monitor')
.should.be.rejected
})
it('destroy monitor created without parameters', function() {
return doCommand('destroy monitor my-monitor')
.should.be.fulfilled
.then(() => doCommand('show monitor my-monitor'))
.should.be.rejected
})
it('will not destroy the same monitor again', function() {
return doCommand('destroy monitor my-monitor')
.should.be.rejected
@ -38,6 +50,11 @@ describe("Create/Destroy Commands", function() {
.should.be.rejected
})
it('will not create monitor with malformed parameters', function() {
return doCommand('create monitor my-monitor mariadbmon not-a-param')
.should.be.rejected
})
it('create monitor with options', function() {
return doCommand('unlink monitor MariaDB-Monitor server4')
.then(() => verifyCommand('create monitor my-monitor mysqlmon --servers server4 --monitor-user maxuser --monitor-password maxpwd',