Skip to content

Commit

Permalink
[test] further expanded test to actually check saved files and update…
Browse files Browse the repository at this point in the history
… env with load
  • Loading branch information
blakmatrix committed Dec 11, 2012
1 parent 6dae54f commit 0f6f1e5
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test/commands/env-test.js
Expand Up @@ -332,8 +332,10 @@ vows.describe('jitsu/commands/env').addBatch({
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' });
}
)
},
function assertion (err) {
assert.ok(!err && fs.existsSync('env.json'));
})
}).addBatch({
'env save barbaz': shouldNodejitsuOk('The specified app should save enviroment variables',
function setup() {
Expand All @@ -350,6 +352,9 @@ vows.describe('jitsu/commands/env').addBatch({
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' });
},
function assertion (err) {
assert.ok(!err && fs.existsSync('env.json'));
}
)
}).addBatch({
Expand All @@ -374,6 +379,9 @@ vows.describe('jitsu/commands/env').addBatch({
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' });
},
function assertion (err) {
assert.ok(!err && fs.existsSync('env_vars.json'));
}
)
}).addBatch({
Expand All @@ -392,12 +400,16 @@ vows.describe('jitsu/commands/env').addBatch({
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' });
},
function assertion (err) {
assert.ok(!err && fs.existsSync('env_vars.json'));
}
)
}).addBatch({
'env load': shouldNodejitsuOk('The current app should load enviroment variables from env.json',
function setup() {
jitsu.prompt.override.confirm = 'yes';
fs.writeFileSync('env.json', JSON.stringify({ foo: 'bar', baz: 'buzz', test: 'truthy1' }, null, 2), 'utf8');
nock('http://api.mockjitsu.com')
.get('/apps/tester/jitsu')
.reply(200, {
Expand All @@ -410,14 +422,15 @@ vows.describe('jitsu/commands/env').addBatch({
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' })
.put('/apps/tester/application', { env: { foo: 'bar', baz: 'buzz', test: 'truthy' } })
.put('/apps/tester/application', { env: { foo: 'bar', baz: 'buzz', test: 'truthy1' } })
.reply(200, '', { 'x-powered-by': 'Nodejitsu' });
}
)
}).addBatch({
'env load barbaz': shouldNodejitsuOk('The specified app should load enviroment variables from env.json',
function setup() {
jitsu.prompt.override.confirm = 'yes';
fs.writeFileSync('env.json', JSON.stringify({ foo: 'bar', baz: 'buzz', test: 'truthy1' }, null, 2), 'utf8');
nock('http://api.mockjitsu.com')
.get('/apps/tester/barbaz')
.reply(200, {
Expand All @@ -430,14 +443,15 @@ vows.describe('jitsu/commands/env').addBatch({
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' })
.put('/apps/tester/barbaz', { env: { foo: 'bar', baz: 'buzz', test: 'truthy' } })
.put('/apps/tester/barbaz', { env: { foo: 'bar', baz: 'buzz', test: 'truthy1' } })
.reply(200, '', { 'x-powered-by': 'Nodejitsu' });
}
)
}).addBatch({
'env load env_vars.json': shouldNodejitsuOk('The current app should load enviroment variables from the specified file',
function setup() {
jitsu.prompt.override.confirm = 'yes';
fs.writeFileSync('env_vars.json', JSON.stringify({ foo: 'bar', baz: 'buzz', test: 'truthy2' }, null, 2), 'utf8');
nock('http://api.mockjitsu.com')
.get('/apps/tester/env_vars.json')
.reply(400, {
Expand All @@ -450,33 +464,34 @@ vows.describe('jitsu/commands/env').addBatch({
app: {
name: 'application',
state: 'stopped',
env: { foo: 'bar', baz: 'buzz', test: 'truthy' },
env: { foo: 'bar', baz: 'buzz', test: 'truthy1' },
subdomain:'application',
scripts: { start: './server.js' },
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' })
.put('/apps/tester/application', { env: { foo: 'bar', baz: 'buzz', test: 'truthy' } })
.put('/apps/tester/application', { env: { foo: 'bar', baz: 'buzz', test: 'truthy2' } })
.reply(200, '', { 'x-powered-by': 'Nodejitsu' });
}
)
}).addBatch({
'env load barbaz env_vars.json': shouldNodejitsuOk('The specified app should load enviroment variables from the specified file',
function setup() {
jitsu.prompt.override.confirm = 'yes';
fs.writeFileSync('env_vars.json', JSON.stringify({ foo: 'bar', baz: 'buzz', test: 'truthy2' }, null, 2), 'utf8');
nock('http://api.mockjitsu.com')
.get('/apps/tester/barbaz')
.reply(200, {
app: {
name: 'barbaz',
state: 'stopped',
env: { foo: 'bar', baz: 'buzz', test: 'truthy' },
env: { foo: 'bar', baz: 'buzz', test: 'truthy1' },
subdomain:'barbaz',
scripts: { start: './server.js' },
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' })
.put('/apps/tester/barbaz', { env: { foo: 'bar', baz: 'buzz', test: 'truthy' } })
.put('/apps/tester/barbaz', { env: { foo: 'bar', baz: 'buzz', test: 'truthy2' } })
.reply(200, '', { 'x-powered-by': 'Nodejitsu' });
}
)
Expand Down

0 comments on commit 0f6f1e5

Please sign in to comment.