@@ -1823,7 +1823,7 @@ describe('Shard', function () {
1823
1823
expect ( reshardCollectionStub . firstCall . args ) . to . deep . equal ( [
1824
1824
'db.coll' ,
1825
1825
{ key : 1 } ,
1826
- { numInitialChunks : 1000 , forceRedistribution : true } ,
1826
+ { forceRedistribution : true } ,
1827
1827
] ) ;
1828
1828
} ) ;
1829
1829
@@ -1860,6 +1860,81 @@ describe('Shard', function () {
1860
1860
{ numInitialChunks : 1 , forceRedistribution : true } ,
1861
1861
] ) ;
1862
1862
} ) ;
1863
+
1864
+ it ( 'allows user to pass collation' , async function ( ) {
1865
+ const expectedResult = { ok : 1 } ;
1866
+
1867
+ const shardCollectionStub = sinon
1868
+ . stub ( shard , 'shardCollection' )
1869
+ . resolves ( expectedResult ) ;
1870
+ const reshardCollectionStub = sinon
1871
+ . stub ( shard , 'reshardCollection' )
1872
+ . resolves ( expectedResult ) ;
1873
+
1874
+ await shard . shardAndDistributeCollection ( 'db.coll' , { key : 1 } , true , {
1875
+ collation : { locale : 'simple' } ,
1876
+ } ) ;
1877
+
1878
+ expect ( shardCollectionStub . calledOnce ) . to . equal ( true ) ;
1879
+ expect ( shardCollectionStub . firstCall . args ) . to . deep . equal ( [
1880
+ 'db.coll' ,
1881
+ {
1882
+ key : 1 ,
1883
+ } ,
1884
+ true ,
1885
+ {
1886
+ collation : { locale : 'simple' } ,
1887
+ } ,
1888
+ ] ) ;
1889
+
1890
+ expect ( reshardCollectionStub . calledOnce ) . to . equal ( true ) ;
1891
+ expect ( reshardCollectionStub . firstCall . args ) . to . deep . equal ( [
1892
+ 'db.coll' ,
1893
+ { key : 1 } ,
1894
+ { collation : { locale : 'simple' } , forceRedistribution : true } ,
1895
+ ] ) ;
1896
+ } ) ;
1897
+
1898
+ it ( 'allows user to pass shard-specific options and ignores them when resharding' , async function ( ) {
1899
+ const expectedResult = { ok : 1 } ;
1900
+
1901
+ const shardCollectionStub = sinon
1902
+ . stub ( shard , 'shardCollection' )
1903
+ . resolves ( expectedResult ) ;
1904
+ const reshardCollectionStub = sinon
1905
+ . stub ( shard , 'reshardCollection' )
1906
+ . resolves ( expectedResult ) ;
1907
+
1908
+ await shard . shardAndDistributeCollection ( 'db.coll' , { key : 1 } , true , {
1909
+ presplitHashedZones : true ,
1910
+ timeseries : {
1911
+ timeField : 'ts' ,
1912
+ } ,
1913
+ } ) ;
1914
+
1915
+ expect ( shardCollectionStub . calledOnce ) . to . equal ( true ) ;
1916
+ expect ( shardCollectionStub . firstCall . args ) . to . deep . equal ( [
1917
+ 'db.coll' ,
1918
+ {
1919
+ key : 1 ,
1920
+ } ,
1921
+ true ,
1922
+ {
1923
+ presplitHashedZones : true ,
1924
+ timeseries : {
1925
+ timeField : 'ts' ,
1926
+ } ,
1927
+ } ,
1928
+ ] ) ;
1929
+
1930
+ expect ( reshardCollectionStub . calledOnce ) . to . equal ( true ) ;
1931
+ expect ( reshardCollectionStub . firstCall . args ) . to . deep . equal ( [
1932
+ 'db.coll' ,
1933
+ { key : 1 } ,
1934
+ { forceRedistribution : true } ,
1935
+ ] ) ;
1936
+ } ) ;
1937
+
1863
1938
it ( 'returns whatever shard.reshardCollection returns' , async function ( ) {
1864
1939
const expectedResult = { ok : 1 } ;
1865
1940
sinon . stub ( shard , 'reshardCollection' ) . resolves ( expectedResult ) ;
0 commit comments