Skip to content

Commit 860f614

Browse files
committed
one more
1 parent 14711c3 commit 860f614

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

packages/compass-global-writes/src/store/index.spec.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ describe('GlobalWritesStore Store', function () {
347347
});
348348

349349
context('invalid and mismatching shard keys', function () {
350-
it('there is no location', async function () {
350+
it('there is no location : invalid', async function () {
351351
const store = createStore({
352352
isNamespaceManaged: () => true,
353353
hasShardKey: () => ({
@@ -364,7 +364,7 @@ describe('GlobalWritesStore Store', function () {
364364
});
365365
});
366366

367-
it('location is not a range', async function () {
367+
it('location is not a range : invalid', async function () {
368368
const store = createStore({
369369
isNamespaceManaged: () => true,
370370
hasShardKey: () => ({
@@ -381,7 +381,7 @@ describe('GlobalWritesStore Store', function () {
381381
});
382382
});
383383

384-
it('secondary key does not match', async function () {
384+
it('secondary key does not match : mismatch', async function () {
385385
const store = createStore({
386386
isNamespaceManaged: () => true,
387387
hasShardKey: () => ({
@@ -398,7 +398,7 @@ describe('GlobalWritesStore Store', function () {
398398
});
399399
});
400400

401-
it('uniqueness does not match', async function () {
401+
it('uniqueness does not match : mismatch', async function () {
402402
const store = createStore({
403403
isNamespaceManaged: () => true,
404404
hasShardKey: () => ({
@@ -414,6 +414,32 @@ describe('GlobalWritesStore Store', function () {
414414
expect(store.getState().status).to.equal('SHARD_KEY_MISMATCH');
415415
});
416416
});
417+
418+
it('mismatch -> unmanaged', async function () {
419+
// initial state - mismatch
420+
const store = createStore({
421+
isNamespaceManaged: () => true,
422+
hasShardKey: () => ({
423+
_id: '123',
424+
key: {
425+
location: 'range',
426+
tertiary: 'range',
427+
},
428+
unique: true,
429+
}),
430+
});
431+
await waitFor(() => {
432+
expect(store.getState().status).to.equal('SHARD_KEY_MISMATCH');
433+
});
434+
435+
// user asks to unmanage
436+
const promise = store.dispatch(unmanageNamespace());
437+
expect(store.getState().status).to.equal(
438+
'UNMANAGING_NAMESPACE_MISMATCH'
439+
);
440+
await promise;
441+
expect(store.getState().status).to.equal('UNSHARDED');
442+
});
417443
});
418444

419445
it('sharding error', async function () {

0 commit comments

Comments
 (0)