Navigation Menu

Skip to content

Commit

Permalink
Move tests of database modifications to the test for Domain
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 2, 2012
1 parent 9ba7649 commit 07a538c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
13 changes: 2 additions & 11 deletions test/api-configuration.test.js
Expand Up @@ -233,14 +233,7 @@ suite('Configuration API', function() {
'Host': 'cloudsearch.localhost'
})
.next(function(response) {
var dump = context.commandSync('dump', {
tables: 'companies'
});
var expectedDump = 'table_create companies_00000000000000000000000000 TABLE_HASH_KEY ShortText\n' +
'table_create companies_00000000000000000000000000_BigramTerms ' +
'TABLE_PAT_KEY|KEY_NORMALIZE ShortText ' +
'--default_tokenizer TokenBigram';
assert.equal(dump, expectedDump);
assert.isTrue((new Domain('companies', context).exists()));

response = toParsedResponse(response);
assert.deepEqual(response.pattern,
Expand Down Expand Up @@ -281,9 +274,7 @@ suite('Configuration API', function() {
'Host': 'cloudsearch.localhost'
})
.next(function(response) {
var dump = context.commandSync('dump');
var expectedDump = '';
assert.equal(dump, expectedDump);
assert.isFalse((new Domain('companies', context).exists()));

response = toParsedResponse(response);
assert.deepEqual(response.pattern,
Expand Down
47 changes: 47 additions & 0 deletions test/database-domain.test.js
Expand Up @@ -259,5 +259,52 @@ suite('database', function() {
assert.deepEqual(fields.sort(sortFields), expected.sort(sortFields));
});
});

suite('database modifications', function() {
var temporaryDatabase;
var context;

setup(function() {
temporaryDatabase = utils.createTemporaryDatabase();
context = temporaryDatabase.get();
});

teardown(function() {
temporaryDatabase.teardown();
temporaryDatabase = undefined;
});

test('createSync', function() {
var domain = new Domain('companies', context);
domain.id = Domain.DEFAULT_ID;
assert.isFalse(domain.exists());

domain.createSync();
assert.isTrue(domain.exists());

var dump = context.commandSync('dump', {
tables: domain.tableName
});
var expectedDump = 'table_create ' + domain.tableName + ' TABLE_HASH_KEY ShortText\n' +
'table_create ' + domain.termsTableName + ' ' +
'TABLE_PAT_KEY|KEY_NORMALIZE ShortText ' +
'--default_tokenizer TokenBigram';
assert.equal(dump, expectedDump);
});

test('deleteSync', function() {
var domain = new Domain('companies', context);
domain.id = Domain.DEFAULT_ID;
domain.createSync();
assert.isTrue(domain.exists());

domain.deleteSync();
assert.isFalse(domain.exists());

var dump = context.commandSync('dump');
var expectedDump = '';
assert.equal(dump, expectedDump);
});
});
});
});

0 comments on commit 07a538c

Please sign in to comment.