@@ -35,6 +35,7 @@ import { dummyOptions } from './helpers.spec';
3535
3636describe ( 'Shard' , function ( ) {
3737 skipIfApiStrict ( ) ;
38+
3839 describe ( 'help' , function ( ) {
3940 const apiClass : any = new Shard ( { } as any ) ;
4041 it ( 'calls help function' , async function ( ) {
@@ -50,6 +51,7 @@ describe('Shard', function () {
5051 ) ;
5152 } ) ;
5253 } ) ;
54+
5355 describe ( 'signatures' , function ( ) {
5456 it ( 'type' , function ( ) {
5557 expect ( signatures . Shard . type ) . to . equal ( 'Shard' ) ;
@@ -70,6 +72,7 @@ describe('Shard', function () {
7072 } ) ;
7173 } ) ;
7274 } ) ;
75+
7376 describe ( 'Metadata' , function ( ) {
7477 describe ( 'toShellResult' , function ( ) {
7578 const mongo = { _uri : 'test_uri' } as Mongo ;
@@ -85,6 +88,7 @@ describe('Shard', function () {
8588 } ) ;
8689 } ) ;
8790 } ) ;
91+
8892 describe ( 'unit' , function ( ) {
8993 let mongo : Mongo ;
9094 let serviceProvider : StubbedInstance < ServiceProvider > ;
@@ -2058,6 +2062,52 @@ describe('Shard', function () {
20582062 expect ( caughtError ) . to . equal ( expectedError ) ;
20592063 } ) ;
20602064 } ) ;
2065+
2066+ describe ( 'moveRange' , function ( ) {
2067+ it ( 'calls serviceProvider.runCommandWithCheck with arg' , async function ( ) {
2068+ serviceProvider . runCommandWithCheck . resolves ( {
2069+ ok : 1 ,
2070+ msg : 'isdbgrid' ,
2071+ } ) ;
2072+ await shard . moveRange ( 'ns' , 'destination' , { key : 0 } , { key : 10 } ) ;
2073+
2074+ expect ( serviceProvider . runCommandWithCheck ) . to . have . been . calledWith (
2075+ ADMIN_DB ,
2076+ {
2077+ moveRange : 'ns' ,
2078+ min : { key : 0 } ,
2079+ max : { key : 10 } ,
2080+ toShard : 'destination' ,
2081+ }
2082+ ) ;
2083+ } ) ;
2084+
2085+ it ( 'returns whatever serviceProvider.runCommandWithCheck returns' , async function ( ) {
2086+ const expectedResult = {
2087+ ok : 1 ,
2088+ operationTime : { $timestamp : { t : 1741189797 , i : 1 } } ,
2089+ } ;
2090+ serviceProvider . runCommandWithCheck . resolves ( expectedResult ) ;
2091+ const result = await shard . moveRange (
2092+ 'ns' ,
2093+ 'destination' ,
2094+ { key : 0 } ,
2095+ { key : 10 }
2096+ ) ;
2097+ expect ( result ) . to . deep . equal ( expectedResult ) ;
2098+ } ) ;
2099+
2100+ it ( 'throws if serviceProvider.runCommandWithCheck rejects' , async function ( ) {
2101+ const expectedError = new Error (
2102+ "Missing required parameter 'min' or 'max'"
2103+ ) ;
2104+ serviceProvider . runCommandWithCheck . rejects ( expectedError ) ;
2105+ const caughtError = await shard
2106+ . moveRange ( 'ns' , 'destination' )
2107+ . catch ( ( e ) => e ) ;
2108+ expect ( caughtError ) . to . equal ( expectedError ) ;
2109+ } ) ;
2110+ } ) ;
20612111 } ) ;
20622112
20632113 describe ( 'integration' , function ( ) {
0 commit comments