Skip to content

Commit c5b5573

Browse files
committed
Fix reconfigure.replication and add unit test for its usage
1 parent acec9f0 commit c5b5573

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/collections/configure/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
InvertedIndexConfigUpdate,
44
MultiTenancyConfigCreate,
55
ReplicationConfigCreate,
6+
ReplicationConfigUpdate,
67
ReplicationDeletionStrategy,
78
ShardingConfigCreate,
89
VectorConfigUpdate,
@@ -234,7 +235,7 @@ const reconfigure = {
234235
asyncEnabled?: boolean;
235236
deletionStrategy?: ReplicationDeletionStrategy;
236237
factor?: number;
237-
}): ReplicationConfigCreate => {
238+
}): ReplicationConfigUpdate => {
238239
return {
239240
asyncEnabled: options.asyncEnabled,
240241
deletionStrategy: options.deletionStrategy,

src/collections/configure/types/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export type ReplicationConfigCreate = RecursivePartial<ReplicationConfig>;
140140

141141
export type ReplicationConfigUpdate = {
142142
asyncEnabled?: boolean;
143-
deletionStragey?: ReplicationDeletionStrategy;
143+
deletionStrategy?: ReplicationDeletionStrategy;
144144
factor?: number;
145145
};
146146

src/collections/configure/unit.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ import {
1414
ModuleConfig,
1515
VectorConfigCreate,
1616
} from '../types/index.js';
17-
import { configure } from './index.js';
17+
import { configure, reconfigure } from './index.js';
1818
import {
1919
InvertedIndexConfigCreate,
2020
MultiTenancyConfigCreate,
2121
ReplicationConfigCreate,
22+
ReplicationConfigUpdate,
2223
ShardingConfigCreate,
2324
VectorIndexConfigFlatCreate,
2425
VectorIndexConfigHNSWCreate,
2526
} from './types/index.js';
2627

27-
describe('Unit testing of the configure factory class', () => {
28+
describe('Unit testing of the configure & reconfigure factory classes', () => {
2829
it('should create the correct InvertedIndexConfig type with all values', () => {
2930
const config = configure.invertedIndex({
3031
bm25b: 0.5,
@@ -76,7 +77,7 @@ describe('Unit testing of the configure factory class', () => {
7677
});
7778
});
7879

79-
it('should create the correct ReplicationConfig type with all values', () => {
80+
it('should create the correct ReplicationConfigCreate type with all values', () => {
8081
const config = configure.replication({
8182
asyncEnabled: true,
8283
deletionStrategy: 'DeleteOnConflict',
@@ -89,6 +90,19 @@ describe('Unit testing of the configure factory class', () => {
8990
});
9091
});
9192

93+
it('should create the correct ReplicationConfigUpdate type with all values', () => {
94+
const config = reconfigure.replication({
95+
asyncEnabled: true,
96+
deletionStrategy: 'DeleteOnConflict',
97+
factor: 2,
98+
});
99+
expect(config).toEqual<ReplicationConfigUpdate>({
100+
asyncEnabled: true,
101+
deletionStrategy: 'DeleteOnConflict',
102+
factor: 2,
103+
});
104+
});
105+
92106
it('should create the correct ShardingConfig type with all values', () => {
93107
const config = configure.sharding({
94108
virtualPerPhysical: 256,

0 commit comments

Comments
 (0)