Files
MaxScale/maxctrl/test/states.js
Markus Mäkelä cf8028a5ce MXS-1300: Un-modularize the core
Making the core a module proved to bring more problems than it solved. For
the sake of simplicity in installation and code coverage reporting, the
core is now completely contained in the `lib/` directory.

Also added preliminary coverage reporting with nyc.
2017-07-23 08:21:00 +03:00

46 lines
1.4 KiB
JavaScript

require('../test_utils.js')()
var ctrl = require('../lib/core.js')
var opts = { extra_args: [ '--quiet'] }
describe("Server states", function() {
before(function() {
return startMaxScale()
.then(function() {
return request.put(host + 'monitors/MySQL-Monitor/stop')
})
})
it('set correct state', function() {
return ctrl.execute('set server server2 master'.split(' '), opts)
.then(function() {
return request.get(host + 'servers/server2', {json: true})
})
.then(function(res) {
res.data.attributes.state.should.match(/Master/)
})
})
it('clear correct state', function() {
return ctrl.execute('clear server server2 master'.split(' '), opts)
.then(function() {
return request.get(host + 'servers/server2', {json: true})
})
.then(function(res) {
res.data.attributes.state.should.not.match(/Master/)
})
})
it('set incorrect state', function() {
return ctrl.execute('set server server2 something'.split(' '), opts)
.should.be.rejected
})
it('clear incorrect state', function() {
return ctrl.execute('clear server server2 something'.split(' '), opts)
.should.be.rejected
})
after(stopMaxScale)
});