Permalink
Browse files

[dist test] Rename config/auth.json to test/fixtures/test-config.json…

… and update tests accordingly
  • Loading branch information...
1 parent e1fe632 commit 7a4baf9e50ab62135060c365a2fe110fac3c33f5 @indexzero indexzero committed Aug 23, 2011
View
@@ -1,5 +1,4 @@
.DS_Store
-config/auth.json
autostart/
autostart/*
local/
@@ -10,6 +9,7 @@ packages/
packages/*
tmp/
tmp/*
+test/fixtures/test-config.json
test/data/repositories/marak-*
test/data/repositories/nodejitsu-*
test/data/repositories/noob-*
View
No changes.
View
@@ -1,6 +0,0 @@
-{
- "auth": {
- "username": "test-username",
- "apiKey": "test-apiKey"
- }
-}
@@ -0,0 +1,13 @@
+{
+ "auth": {
+ "username": "test-username",
+ "apiKey": "test-apiKey"
+ },
+ "loggly": {
+ "subdomain": "your-subdomain",
+ "inputs": {
+ "haibu": "your-input-token-for-haibu-logs",
+ "user": "your-input-token-for-user-logs"
+ }
+ }
+}
View
@@ -15,56 +15,50 @@ var assert = require('assert'),
haibu = require('../lib/haibu');
var helpers = exports,
- configMissing = false,
testConfig;
-function showConfigError () {
- if (!configMissing) {
- console.log("Config file config/auth.json doesn't have valid data. Skipping remote tests");
- configMissing = true;
+function showConfigWarning (requireAuth) {
+ if ((!testConfig || !testConfig.auth ||
+ testConfig.auth.username === 'test-username' ||
+ testConfig.auth.apiKey === 'test-apiKey')
+ && requireAuth) {
+ console.log("Config file test/fixtures/test-config.json doesn't have valid data. Skipping remote tests");
+ process.exit(1);
}
}
-helpers.loadConfig = function () {
- //
- // TODO (olauzon) load all /config/*.json at once in parallel
- //
- var configFile = path.join(__dirname, '..', 'config', 'auth.json');
-
+helpers.loadConfig = function (requireAuth) {
+ function showConfig () {
+ showConfigWarning();
+ return testConfig;
+ }
+
+ if (testConfig) {
+ return showConfig();
+ }
+
try {
- var stats = fs.statSync(configFile),
+ var configFile = path.join(__dirname, 'fixtures', 'test-config.json'),
config = JSON.parse(fs.readFileSync(configFile).toString());
- if ((config.auth.username === 'test-username') ||
- (config.auth.apiKey === 'test-apiKey')) {
- return showConfigError();
- }
-
testConfig = config;
- return config;
+ return showConfig();
}
catch (ex) {
- return showConfigError();
+ return showConfig();
}
};
-Object.defineProperty(helpers, 'auth', {
- get: function () {
- if (helpers.loadConfig() !== null) {
- return helpers.loadConfig().auth;
- }
- }
-});
-
helpers.cleanAutostart = function (callback) {
exec('rm -rf ' + path.join(haibu.config.get('directories:autostart'), '*'), callback);
};
helpers.init = function (callback) {
+ var config = helpers.loadConfig();
helpers.cleanAutostart(function () {
haibu.init({ env: 'development' }, function (err) {
haibu.use(haibu.plugins.logger, {
- loggly: haibu.config.get('loggly'),
+ loggly: config.loggly || haibu.config.get('loggly'),
console: {
level: 'silly',
silent: true
@@ -15,24 +15,28 @@ var assert = require('assert'),
RemoteFile = require('../../lib/haibu/repositories/remote-file').RemoteFile;
var ipAddress = '127.0.0.1',
- port = 9000, remoteFile,
- app = {
- "name": "test",
- "user": "marak",
- "directories": {
- "home": "hellonode"
- },
- "repository": {
- "auth": helpers.auth,
- "protocol": "cloudfiles",
- "container": "nodejitsu-apps",
- "filename": "hellonode.tar.gz",
- "type": "tar"
- },
- "scripts": {
- "start": "server.js"
- }
- };
+ port = 9000,
+ config = helpers.loadConfig(true),
+ remoteFile,
+ app;
+
+app = {
+ "name": "test",
+ "user": "marak",
+ "directories": {
+ "home": "hellonode"
+ },
+ "repository": {
+ "auth": config.auth,
+ "protocol": "cloudfiles",
+ "container": "nodejitsu-apps",
+ "filename": "hellonode.tar.gz",
+ "type": "tar"
+ },
+ "scripts": {
+ "start": "server.js"
+ }
+};
var suite = vows.describe('haibu/repositories/remote-file').addBatch(
helpers.requireInit(function () {
@@ -92,9 +96,7 @@ var suite = vows.describe('haibu/repositories/remote-file').addBatch(
}
});
-if (helpers.auth) {
- //
- // If there is no config file, we can't run the remote tests
- //
- suite.export(module);
-}
+//
+// Export the suite to the test module
+//
+suite.export(module);
@@ -14,32 +14,37 @@ var assert = require('assert'),
var ipAddress = '127.0.0.1',
port = 9000,
- httpApp = {
- "name": "test",
- "user": "marak",
- "repository": {
- "type": "tar",
- "protocol": "http",
- "url": "http://c0027507.cdn1.cloudfiles.rackspacecloud.com/hellonode.tar.gz"
- },
- "scripts": {
- "start": "server.js"
- }
- },
- cloudfilesApp = {
- "name": "test",
- "user": "charlie",
- "repository": {
- "type": "tar",
- "protocol": "cloudfiles",
- "filename": "hellonode.tar.gz",
- "container": "nodejitsu-apps",
- "auth": helpers.auth
- },
- "scripts": {
- "start": "server.js"
- }
- };
+ cloudfilesApp,
+ httpApp,
+ config = helpers.loadConfig(true);
+
+httpApp = {
+ "name": "test",
+ "user": "marak",
+ "repository": {
+ "type": "tar",
+ "protocol": "http",
+ "url": "http://c0027507.cdn1.cloudfiles.rackspacecloud.com/hellonode.tar.gz"
+ },
+ "scripts": {
+ "start": "server.js"
+ }
+};
+
+cloudfilesApp = {
+ "name": "test",
+ "user": "charlie",
+ "repository": {
+ "type": "tar",
+ "protocol": "cloudfiles",
+ "filename": "hellonode.tar.gz",
+ "container": "nodejitsu-apps",
+ "auth": config.auth
+ },
+ "scripts": {
+ "start": "server.js"
+ }
+};
// Create the vows test suite
var suite = vows.describe('haibu/repositories/tar').addBatch(helpers.requireInit());
@@ -86,9 +91,7 @@ var suite = vows.describe('haibu/repositories/tar').addBatch(helpers.requireInit
suite.addBatch(batch);
});
-if (helpers.auth) {
- //
- // If there is no config file, we can't run the remote tests
- //
- suite.export(module);
-}
+//
+// Export the suite to the test module
+//
+suite.export(module);
@@ -14,32 +14,37 @@ var assert = require('assert'),
var ipAddress = '127.0.0.1',
port = 9000,
- httpApp = {
- "name": "test",
- "user": "marak",
- "repository": {
- "type": "zip",
- "protocol": "http",
- "url": "http://c0027507.cdn1.cloudfiles.rackspacecloud.com/hellonode.zip"
- },
- "scripts": {
- "start": "server.js"
- }
- },
- cloudfilesApp = {
- "name": "test",
- "user": "charlie",
- "repository": {
- "type": "zip",
- "protocol": "cloudfiles",
- "filename": "hellonode.zip",
- "container": "nodejitsu-apps",
- "auth": helpers.auth
- },
- "scripts": {
- "start": "server.js"
- }
- };
+ config = helpers.loadConfig(true),
+ cloudfilesApp,
+ httpApp;
+
+httpApp = {
+ "name": "test",
+ "user": "marak",
+ "repository": {
+ "type": "zip",
+ "protocol": "http",
+ "url": "http://c0027507.cdn1.cloudfiles.rackspacecloud.com/hellonode.zip"
+ },
+ "scripts": {
+ "start": "server.js"
+ }
+};
+
+cloudfilesApp = {
+ "name": "test",
+ "user": "charlie",
+ "repository": {
+ "type": "zip",
+ "protocol": "cloudfiles",
+ "filename": "hellonode.zip",
+ "container": "nodejitsu-apps",
+ "auth": config.auth
+ },
+ "scripts": {
+ "start": "server.js"
+ }
+};
// Create the vows test suite
var suite = vows.describe('haibu/repositories/zip').addBatch(

0 comments on commit 7a4baf9

Please sign in to comment.