Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #316 from mtipnis/master

Adding test case for aliases. Also shortened some payload to tailor it for the specific test
  • Loading branch information...
commit 37ea1ec45753e31d2f4e49095926b616135d3339 2 parents e2c6886 + 94b78ed
@s3u s3u authored
Showing with 45 additions and 5 deletions.
  1. +45 −5 modules/engine/test/select-test.js
View
50 modules/engine/test/select-test.js
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-var _ = require('underscore');
+var _ = require('underscore'),
+ util = require('util');
var Engine = require('../lib/engine');
@@ -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>'
}
],
@@ -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);
+
+ }
+ }
+ }
+
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.