@@ -35,6 +35,7 @@ import { dummyOptions } from './helpers.spec';
35
35
36
36
describe ( 'Shard' , function ( ) {
37
37
skipIfApiStrict ( ) ;
38
+
38
39
describe ( 'help' , function ( ) {
39
40
const apiClass : any = new Shard ( { } as any ) ;
40
41
it ( 'calls help function' , async function ( ) {
@@ -50,6 +51,7 @@ describe('Shard', function () {
50
51
) ;
51
52
} ) ;
52
53
} ) ;
54
+
53
55
describe ( 'signatures' , function ( ) {
54
56
it ( 'type' , function ( ) {
55
57
expect ( signatures . Shard . type ) . to . equal ( 'Shard' ) ;
@@ -70,6 +72,7 @@ describe('Shard', function () {
70
72
} ) ;
71
73
} ) ;
72
74
} ) ;
75
+
73
76
describe ( 'Metadata' , function ( ) {
74
77
describe ( 'toShellResult' , function ( ) {
75
78
const mongo = { _uri : 'test_uri' } as Mongo ;
@@ -85,6 +88,7 @@ describe('Shard', function () {
85
88
} ) ;
86
89
} ) ;
87
90
} ) ;
91
+
88
92
describe ( 'unit' , function ( ) {
89
93
let mongo : Mongo ;
90
94
let serviceProvider : StubbedInstance < ServiceProvider > ;
@@ -2058,6 +2062,52 @@ describe('Shard', function () {
2058
2062
expect ( caughtError ) . to . equal ( expectedError ) ;
2059
2063
} ) ;
2060
2064
} ) ;
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
+ } ) ;
2061
2111
} ) ;
2062
2112
2063
2113
describe ( 'integration' , function ( ) {
0 commit comments