From 57471c7baae2a255191ec148b18303c59b0b1aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 10 Aug 2018 21:46:38 +0300 Subject: [PATCH] Improve MaxCtrl test coverage A few missing cases that simple to solve were reported by the coverage tool. --- maxctrl/test/api.js | 10 +++++++++- maxctrl/test/call.js | 5 +++++ maxctrl/test/createdestroy.js | 11 +++++++++++ maxctrl/test/diagnostics.js | 2 ++ maxctrl/test/special.js | 5 +++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/maxctrl/test/api.js b/maxctrl/test/api.js index f6134c1ea..62ec3ba0e 100644 --- a/maxctrl/test/api.js +++ b/maxctrl/test/api.js @@ -16,7 +16,7 @@ describe("API", function() { }) }) - it('sums integer values', function() { + it('sums zero integer values', function() { return doCommand('api get servers data[].attributes.statistics.connections --sum') .then((res) => { js = JSON.parse(res) @@ -24,6 +24,14 @@ describe("API", function() { }) }) + it('sums non-zero integer values', function() { + return doCommand('api get --sum maxscale/threads data[].attributes.stats.reads') + .then((res) => { + js = JSON.parse(res) + js.should.be.a('number') + }) + }) + it('does not sum string values', function() { return doCommand('api get servers data[].id --sum') .then((res) => { diff --git a/maxctrl/test/call.js b/maxctrl/test/call.js index 8c346a6fc..ca4cabd8e 100644 --- a/maxctrl/test/call.js +++ b/maxctrl/test/call.js @@ -20,5 +20,10 @@ describe("Module Commands", function() { .should.be.rejected }) + it('call unknown command', function() { + return doCommand('call command mariadbmon log') + .should.be.rejected + }) + after(stopMaxScale) }); diff --git a/maxctrl/test/createdestroy.js b/maxctrl/test/createdestroy.js index de2d6ea62..0e4e745d0 100644 --- a/maxctrl/test/createdestroy.js +++ b/maxctrl/test/createdestroy.js @@ -239,5 +239,16 @@ describe("Create/Destroy Commands", function() { .should.be.fulfilled }) + it('create filter with no parameters', function() { + return verifyCommand('create filter test-filter hintfilter', + 'filters/test-filter') + .should.be.fulfilled + }) + + it('destroy filter with no parameters', function() { + return doCommand('destroy filter test-filter') + .should.be.fulfilled + }) + after(stopMaxScale) }); diff --git a/maxctrl/test/diagnostics.js b/maxctrl/test/diagnostics.js index dc3acacae..1ca3ae672 100644 --- a/maxctrl/test/diagnostics.js +++ b/maxctrl/test/diagnostics.js @@ -10,6 +10,7 @@ var tests = [ 'list modules', 'list users', 'list commands', + 'list threads', 'show servers', 'show services', 'show monitors', @@ -19,6 +20,7 @@ var tests = [ 'show maxscale', 'show logging', 'show threads', + 'show thread 0', 'show server server1', 'show service RW-Split-Router', 'show monitor MariaDB-Monitor', diff --git a/maxctrl/test/special.js b/maxctrl/test/special.js index 48f01028d..cbe39ce53 100644 --- a/maxctrl/test/special.js +++ b/maxctrl/test/special.js @@ -70,6 +70,11 @@ describe("Library invocation", function() { .should.be.fulfilled }) + it('no command', function() { + return ctrl.execute([], {}) + .should.be.rejected + }) + it('reject on connection failure', function() { stopMaxScale() .then(function() {