Skip to content

Commit

Permalink
Merge pull request #316 from mtipnis/master
Browse files Browse the repository at this point in the history
Adding test case for aliases. Also shortened some payload to tailor it for the specific test
  • Loading branch information
Subbu Allamaraju committed Mar 2, 2012
2 parents e2c6886 + 94b78ed commit 37ea1ec
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions modules/engine/test/select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* limitations under the License.
*/

var _ = require('underscore');
var _ = require('underscore'),
util = require('util');

var Engine = require('../lib/engine');

Expand Down Expand Up @@ -95,10 +96,6 @@ var cooked = {
'<title>Mini : Clubman S 2011 MINI COOPER S CLUBMAN*CONVENIENCE PKG,PREMIUM PKG,XENON LIGHTS=SWEET RIDE</title>'+
'<primaryCategory><categoryName>Clubman</categoryName> </primaryCategory>'+
'<sellingStatus> <currentPrice currencyId="USD">16000.0</currentPrice></sellingStatus></item>'+
'<item><itemId>120854322916</itemId>'+
'<title>COOPER CROUSE HINDS APJ6485 ARKTITE PLUG RECEPTACLE PIN SLEEVE 600V 60A 3W 43632</title>' +
'<primaryCategory><categoryName>Receptacles &amp; Outlets</categoryName></primaryCategory>'+
'<sellingStatus><currentPrice currencyId="USD">169.99</currentPrice></sellingStatus></item>'+
'</findItemsByKeywordsResponse>'
}
],
Expand All @@ -122,6 +119,49 @@ var cooked = {
}
}

},
selectsomealiases: {
ports: [
{
port: 3000,
status: 200,
type: "application",
subType: "xml",
payload:
'<?xml version="1.0"?>' +
'<findItemsByKeywordsResponse>' +
'<item><itemId>220944750971</itemId>'+
'<title>Mini : Clubman S 2011 MINI COOPER S CLUBMAN*CONVENIENCE PKG,PREMIUM PKG,XENON LIGHTS=SWEET RIDE</title>'+
'<primaryCategory><categoryName>Clubman</categoryName> </primaryCategory>'+
'<sellingStatus> <currentPrice currencyId="USD">16000.0</currentPrice></sellingStatus></item>'+
'</findItemsByKeywordsResponse>'
}
],
script: 'create table finditems1 on select get from "http://localhost:3000"' +
'resultset "findItemsByKeywordsResponse.item" ' +
'web = select title as title, itemId as id, primaryCategory.categoryName as cat, sellingStatus.currentPrice as price from finditems1 where keywords="cooper" and FreeShippingOnly = "true" and MinPrice = "100" limit 10 offset 20'+
'return "{web}"',
udf: {
test : function (test, err, result) {
if(err) {
console.log(util.inspect(err,false,null));
test.fail('got error: ' + err.stack || err);

}
else {
test.equals(result.headers['content-type'], 'application/json', 'HTML expected');
test.ok(_.isArray(result.body), 'expected an array');
test.ok(result.body.length > 0, 'expected some items');
test.ok(_.isObject(result.body[0]), 'expected object in the array');
test.ok(result.body[0].title);
test.ok(result.body[0].id);
test.ok(result.body[0].cat);
test.ok(result.body[0].price);

}
}
}

}
}

Expand Down

0 comments on commit 37ea1ec

Please sign in to comment.