Skip to content

Commit 3233120

Browse files
authored
Merge pull request #216 from gregolsky/RDBC-404
RDBC-404 fix GetDatabaseNamesCommand failing for an empty server
2 parents f58475e + 7d5501a commit 3233120

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/ServerWide/Operations/GetDatabaseNamesOperation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class GetDatabaseNamesCommand extends RavenCommand<string[]> {
5454
const results = await this._defaultPipeline(_ => body = _)
5555
.process(bodyStream);
5656
const { databases } = results as any;
57-
if (!databases || !Array.isArray(databases) || !databases.length) {
57+
if (!databases || !Array.isArray(databases)) {
5858
this._throwInvalidResponse();
5959
}
6060

test/Issues/RDBC_404.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import * as assert from "assert";
2+
import { testContext, disposeTestDocumentStore } from "../Utils/TestUtil";
3+
4+
import DocumentStore, {
5+
IDocumentStore, GetDatabaseNamesOperation, DeleteDatabasesOperation,
6+
} from "../../src";
7+
import { delay } from "../../src/Utility/PromiseUtil";
8+
9+
describe("RDBC-404", function () {
10+
11+
let store: IDocumentStore;
12+
13+
beforeEach(async function () {
14+
testContext.customizeStore = async (store) => {
15+
16+
store.conventions.findCollectionNameForObjectLiteral = x => "test";
17+
};
18+
store = await testContext.getDocumentStore();
19+
});
20+
21+
afterEach(async () => {
22+
await disposeTestDocumentStore(store);
23+
});
24+
25+
it("GetDatabaseNamesOperation does not fail for an empty server", async () => {
26+
27+
const store2 = new DocumentStore(store.urls, null);
28+
try {
29+
store2.initialize();
30+
try {
31+
store.dispose();
32+
// tslint:disable-next-line: no-empty
33+
} catch {}
34+
35+
const dbs = await store2.maintenance.server.send(new GetDatabaseNamesOperation(0, 10));
36+
await store2.maintenance.server.send(new DeleteDatabasesOperation({
37+
databaseNames: dbs,
38+
hardDelete: true
39+
}));
40+
41+
await store.maintenance.server.send(new GetDatabaseNamesOperation(0, 10));
42+
} finally {
43+
store2.dispose();
44+
}
45+
});
46+
});

0 commit comments

Comments
 (0)