Permalink
Browse files

Test static routing against direct S3 content

Compare the file returned from the static routes with the file returned
directly from the S3 URL.
  • Loading branch information...
prashtx committed Aug 9, 2012
1 parent b5a911c commit ca1fbc36253b9eecce8b4ee47578ef6e7c99f348
Showing with 66 additions and 1 deletion.
  1. +4 −0 settings-test.js
  2. +4 −0 settings.js
  3. +58 −1 test/test.static.js
View
@@ -24,5 +24,9 @@ settings.psqlName = process.env.PSQL_NAME;
settings.psqlUser = process.env.PSQL_USER;
settings.psqlPass = process.env.PSQL_PASS;
+// Static apps
+settings.mobilePrefix = process.env.REMOTE_MOBILE_PREFIX;
+settings.adminPrefix = process.env.REMOTE_ADMIN_PREFIX;
+
// Web server
settings.port = 3030;
View
@@ -23,5 +23,9 @@ settings.psqlName = process.env.PSQL_NAME;
settings.psqlUser = process.env.PSQL_USER;
settings.psqlPass = process.env.PSQL_PASS;
+// Static apps
+settings.mobilePrefix = process.env.REMOTE_MOBILE_PREFIX;
+settings.adminPrefix = process.env.REMOTE_ADMIN_PREFIX;
+
// Web server
settings.port = process.env.PORT || 3000;
View
@@ -5,6 +5,7 @@
var server = require('../web.js');
var request = require('request');
var should = require('should');
+var crypto = require('crypto');
var settings = require('../settings-test.js');
@@ -20,6 +21,22 @@ suite('Static', function () {
});
suite('Mobile client', function () {
+ var digest;
+
+ suiteSetup(function (done) {
+ request({
+ url: settings.mobilePrefix + '/index.html'
+ }, function (error, response, body) {
+ if (error) { return done(error); }
+
+ var hash = crypto.createHash('md5');
+ hash.update(body);
+ digest = hash.digest('hex');
+
+ done();
+ });
+ });
+
test('base without slash', function (done) {
request({
url: BASEURL + '/mobile'
@@ -28,6 +45,10 @@ suite('Static', function () {
response.statusCode.should.equal(200);
response.should.be.html;
+ var hash = crypto.createHash('md5');
+ hash.update(body);
+ hash.digest('hex').should.equal(digest);
+
done();
});
});
@@ -40,6 +61,10 @@ suite('Static', function () {
response.statusCode.should.equal(200);
response.should.be.html;
+ var hash = crypto.createHash('md5');
+ hash.update(body);
+ hash.digest('hex').should.equal(digest);
+
done();
});
});
@@ -52,12 +77,32 @@ suite('Static', function () {
response.statusCode.should.equal(200);
response.should.be.html;
+ var hash = crypto.createHash('md5');
+ hash.update(body);
+ hash.digest('hex').should.equal(digest);
+
done();
});
});
});
- suite('Browser app', function () {
+ suite('Admin app', function () {
+ var digest;
+
+ suiteSetup(function (done) {
+ request({
+ url: settings.adminPrefix + '/index.html'
+ }, function (error, response, body) {
+ if (error) { return done(error); }
+
+ var hash = crypto.createHash('md5');
+ hash.update(body);
+ digest = hash.digest('hex');
+
+ done();
+ });
+ });
+
test('base without slash', function (done) {
request({
url: BASEURL
@@ -66,6 +111,10 @@ suite('Static', function () {
response.statusCode.should.equal(200);
response.should.be.html;
+ var hash = crypto.createHash('md5');
+ hash.update(body);
+ hash.digest('hex').should.equal(digest);
+
done();
});
});
@@ -78,6 +127,10 @@ suite('Static', function () {
response.statusCode.should.equal(200);
response.should.be.html;
+ var hash = crypto.createHash('md5');
+ hash.update(body);
+ hash.digest('hex').should.equal(digest);
+
done();
});
});
@@ -90,6 +143,10 @@ suite('Static', function () {
response.statusCode.should.equal(200);
response.should.be.html;
+ var hash = crypto.createHash('md5');
+ hash.update(body);
+ hash.digest('hex').should.equal(digest);
+
done();
});
});

0 comments on commit ca1fbc3

Please sign in to comment.