-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from gregolsky/v4.1
RDBC-265
- Loading branch information
Showing
4 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as mocha from "mocha"; | ||
import * as assert from "assert"; | ||
import { User, Company, Order } from "../Assets/Entities"; | ||
import { testContext, disposeTestDocumentStore } from "../Utils/TestUtil"; | ||
|
||
import { | ||
RavenErrorType, | ||
IDocumentStore, | ||
SeedIdentityForCommand, | ||
GetIdentitiesOperation, | ||
} from "../../src"; | ||
|
||
describe("RDBC-265", function () { | ||
|
||
let store: IDocumentStore; | ||
|
||
beforeEach(async function () { | ||
store = await testContext.getDocumentStore(); | ||
}); | ||
|
||
afterEach(async () => | ||
await disposeTestDocumentStore(store)); | ||
|
||
it("sets identity back to 0 only when forced", async () => { | ||
{ | ||
const session = store.openSession(); | ||
const user = Object.assign(new User(), { lastName: "Adi" }); | ||
await session.store(user, "users|"); | ||
await session.saveChanges(); | ||
assert.strictEqual(user.id, "users/1"); | ||
} | ||
|
||
let identities = await store.maintenance.send(new GetIdentitiesOperation()); | ||
assert.strictEqual(identities["users|"], 1); | ||
|
||
let command = new SeedIdentityForCommand("users", 0); | ||
await store.getRequestExecutor().execute(command); | ||
|
||
identities = await store.maintenance.send(new GetIdentitiesOperation()); | ||
assert.strictEqual(identities["users|"], 1); | ||
|
||
command = new SeedIdentityForCommand("users", 0, true); | ||
await store.getRequestExecutor().execute(command); | ||
|
||
identities = await store.maintenance.send(new GetIdentitiesOperation()); | ||
assert.strictEqual(identities["users|"], 0); | ||
|
||
// the below won't work however | ||
// due to https://github.com/ravendb/ravendb/blob/v4.1/test/SlowTests/Issues/RavenDB_9576.cs#L14 | ||
// { | ||
// const session = store.openSession(); | ||
// const user = Object.assign(new User(), { lastName: "Avivi" }); | ||
// await session.store(user, "users|"); | ||
// await session.saveChanges(); | ||
// assert.strictEqual(user.id, "users/1"); | ||
// } | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters