Skip to content

Commit 46cd2b3

Browse files
committed
add test for RavenDB-12132
1 parent b128a26 commit 46cd2b3

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import * as mocha from "mocha";
2+
import * as assert from "assert";
3+
import { User, Company, Order } from "../../Assets/Entities";
4+
import { assertThat } from "../../Utils/AssertExtensions";
5+
import { testContext, disposeTestDocumentStore } from "../../Utils/TestUtil";
6+
7+
import {
8+
RavenErrorType,
9+
IDocumentStore,
10+
PutCompareExchangeValueOperation,
11+
SessionOptions,
12+
} from "../../../src";
13+
14+
describe.only("RavenDB-12132", function () {
15+
16+
let store: IDocumentStore;
17+
18+
beforeEach(async function () {
19+
store = await testContext.getDocumentStore();
20+
});
21+
22+
afterEach(async () =>
23+
await disposeTestDocumentStore(store));
24+
25+
it("canPutObjectWithId", async () => {
26+
{
27+
const user = Object.assign(new User(), { id: "users/1", name: "Grisha" });
28+
29+
const res = await store.operations.send(
30+
new PutCompareExchangeValueOperation<User>("test", user, 0));
31+
32+
assertThat(res.successful)
33+
.isTrue();
34+
35+
assertThat(res.value.name)
36+
.isEqualTo("Grisha");
37+
assertThat(res.value.id)
38+
.isEqualTo("users/1");
39+
40+
}
41+
});
42+
43+
it("canCreateClusterTransactionRequest1", async function () {
44+
const user = Object.assign(new User(), { id: "this/is/my/id", name: "Grisha" });
45+
const sessionOpts = { transactionMode: "ClusterWide" } as SessionOptions;
46+
47+
const session = store.openSession(sessionOpts);
48+
session.advanced.clusterTransaction.createCompareExchangeValue<User>("usernames/ayende", user);
49+
await session.saveChanges();
50+
const userFromCluster = (await session.advanced.clusterTransaction
51+
.getCompareExchangeValue<User>("usernames/ayende")).value;
52+
assertThat(userFromCluster.name)
53+
.isEqualTo(user.name);
54+
assertThat(userFromCluster.id)
55+
.isEqualTo(user.id);
56+
});
57+
});

0 commit comments

Comments
 (0)