Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system tests: search: delete documents individually #784

Merged
merged 1 commit into from
Aug 6, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 14 additions & 41 deletions system-test/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function deleteDocument(document, callback) {
}

function deleteIndexContents(index, callback) {
index.getDocuments(function(err, documents) {
index.getDocuments({ view: 'ID_ONLY' }, function(err, documents) {
if (err) {
callback(err);
return;
Expand All @@ -44,17 +44,6 @@ function deleteIndexContents(index, callback) {
});
}

function deleteAllDocuments(callback) {
search.getIndexes(function(err, indexes) {
if (err) {
callback(err);
return;
}

async.eachLimit(indexes, MAX_PARALLEL, deleteIndexContents, callback);
});
}

function generateIndexName() {
return 'gcloud-test-index-' + uuid.v1();
}
Expand All @@ -67,12 +56,8 @@ describe('Search', function() {
var INDEX_NAME = generateIndexName();
var index = search.index(INDEX_NAME);

before(function(done) {
deleteAllDocuments(done);
});

after(function(done) {
deleteAllDocuments(done);
deleteIndexContents(index, done);
});

describe('creating an index', function() {
Expand Down Expand Up @@ -140,21 +125,15 @@ describe('Search', function() {
var document;

before(function(done) {
async.series([
deleteAllDocuments,

function(next) {
index.createDocument(TEST_DOCUMENT_JSON, function(err, doc) {
if (err) {
next(err);
return;
}

document = doc;
next();
});
index.createDocument(TEST_DOCUMENT_JSON, function(err, doc) {
if (err) {
done(err);
return;
}
], done);

document = doc;
done();
});
});

after(function(done) {
Expand All @@ -169,14 +148,6 @@ describe('Search', function() {
});
});

it('should get all documents with autoPaginate', function(done) {
index.getDocuments({ autoPaginate: true }, function(err, documents) {
assert.ifError(err);
assert.strictEqual(documents.length, 1);
done();
});
});

it('should get all documents in stream mode', function(done) {
var resultsMatched = 0;

Expand Down Expand Up @@ -228,7 +199,8 @@ describe('Search', function() {
document.getMetadata(function(err) {
assert.ifError(err);
assert.deepEqual(document.toJSON(), TEST_DOCUMENT_JSON);
done();

document.delete(done);
});
});
});
Expand All @@ -239,7 +211,8 @@ describe('Search', function() {
document.getMetadata(function(err) {
assert.ifError(err);
assert.deepEqual(document.toJSON(), TEST_DOCUMENT_JSON);
done();

document.delete(done);
});
});
});
Expand Down