Navigation Menu

Skip to content

Commit

Permalink
Add tests for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 9, 2012
1 parent 5b2b9a7 commit cfce7d2
Showing 1 changed file with 66 additions and 3 deletions.
69 changes: 66 additions & 3 deletions test/gcs-commands.test.js
Expand Up @@ -633,7 +633,7 @@ suite('gcs-post-sdf', function() {
domain.getIndexField('product').setType('literal').createSync();
}

test('post add sdf', function(done) {
test('post add sdf json', function(done) {
setupDomain();
var batchFile = path.join(fixturesDirectory, 'add.sdf.json');
utils
Expand All @@ -660,7 +660,7 @@ suite('gcs-post-sdf', function() {
});
});

test('post delete sdf', function(done) {
test('post delete sdf json', function(done) {
setupDomain();
var batchFile = path.join(fixturesDirectory, 'delete.sdf.json');
utils
Expand Down Expand Up @@ -691,7 +691,7 @@ suite('gcs-post-sdf', function() {
});
});

test('post invalid sdf', function(done) {
test('post invalid sdf json', function(done) {
setupDomain();
var batchFile = path.join(fixturesDirectory, 'invalid.sdf.json');
utils
Expand Down Expand Up @@ -726,6 +726,69 @@ suite('gcs-post-sdf', function() {
});
});

test('post no source', function(done) {
setupDomain();
utils
.run('gcs-post-sdf',
'--domain-name', 'companies',
'--database-path', temporaryDatabase.path)
.next(function(result) {
assert.deepEqual({ code: result.code,
message: result.output.stdout },
{ code: 1,
message: 'You must specify the source SDF.\n' },
result.output.stderr);
done();
})
.error(function(e) {
done(e);
});
});

test('post unknown format file', function(done) {
setupDomain();
var batchFile = path.join(__dirname, 'fixtures', 'synonyms.txt');
utils
.run('gcs-post-sdf',
'--domain-name', 'companies',
'--source', batchFile,
'--database-path', temporaryDatabase.path)
.next(function(result) {
assert.deepEqual({ code: result.code,
message: result.output.stdout },
{ code: 1,
message: 'Processing: ' + batchFile + '\n' +
'Unknown format\n' },
result.output.stderr);
done();
})
.error(function(e) {
done(e);
});
});

test('post missing file', function(done) {
setupDomain();
var batchFile = path.join(__dirname, 'fixtures', 'not-exists.json');
utils
.run('gcs-post-sdf',
'--domain-name', 'companies',
'--source', batchFile,
'--database-path', temporaryDatabase.path)
.next(function(result) {
assert.deepEqual({ code: result.code,
message: result.output.stdout },
{ code: 1,
message: 'Processing: ' + batchFile + '\n' +
'No such file\n' },
result.output.stderr);
done();
})
.error(function(e) {
done(e);
});
});

test('post not-existing domain', function(done) {
utils
.run('gcs-post-sdf',
Expand Down

0 comments on commit cfce7d2

Please sign in to comment.