Add classification test case
Also removed the dead code that was never used to get coverage to 100%.
This commit is contained in:
@ -28,11 +28,13 @@ exports.handler = function (argv) {
|
||||
return doRequest(host,
|
||||
'maxscale/query_classifier/classify?sql=' + argv.statement,
|
||||
(res) => {
|
||||
var a = res.data.attributes.parameters.functions.map((f) => {
|
||||
return f.name + ': (' + f.arguments.join(', ') + ')'
|
||||
});
|
||||
if (res.data.attributes.parameters.functions) {
|
||||
var a = res.data.attributes.parameters.functions.map((f) => {
|
||||
return f.name + ': (' + f.arguments.join(', ') + ')'
|
||||
});
|
||||
|
||||
res.data.attributes.parameters.functions = a;
|
||||
res.data.attributes.parameters.functions = a;
|
||||
}
|
||||
|
||||
return formatResource(classify_fields, res.data)
|
||||
})
|
||||
@ -44,14 +46,6 @@ exports.builder = function(yargs) {
|
||||
.epilog('Classify the statement using MaxScale and display the result. ' +
|
||||
'The possible values for "Parse result", "Type mask" and "Operation" ' +
|
||||
'can be looked up in ' +
|
||||
'https://github.com/mariadb-corporation/MaxScale/blob/' +
|
||||
'2.3/include/maxscale/query_classifier.h')
|
||||
'https://github.com/mariadb-corporation/MaxScale/blob/2.3/include/maxscale/query_classifier.h')
|
||||
.help()
|
||||
.command('*', 'the default command', {}, function(argv) {
|
||||
console.log("*");
|
||||
maxctrl(argv, function(host) {
|
||||
console.log(argv.statement);
|
||||
return error('Unknown command. See output of `help stop` for a list of commands.')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
27
maxctrl/test/classify.js
Normal file
27
maxctrl/test/classify.js
Normal file
@ -0,0 +1,27 @@
|
||||
require('../test_utils.js')()
|
||||
|
||||
describe("Classify Commands", function() {
|
||||
before(startMaxScale)
|
||||
|
||||
it('classifies query', function() {
|
||||
return doCommand('--tsv classify SELECT\t1')
|
||||
.should.eventually.match(/QC_QUERY_PARSED/)
|
||||
})
|
||||
|
||||
it('classifies query with function', function() {
|
||||
return doCommand('--tsv classify SELECT\tspecial_function("hello",5)')
|
||||
.should.eventually.match(/special_function/)
|
||||
})
|
||||
|
||||
it('classifies invalid query', function() {
|
||||
return doCommand('--tsv classify This-should-fail')
|
||||
.should.eventually.match(/QC_QUERY_INVALID/)
|
||||
})
|
||||
|
||||
it('rejects no query', function() {
|
||||
return doCommand('classify')
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
after(stopMaxScale)
|
||||
});
|
Reference in New Issue
Block a user