@@ -1790,6 +1790,120 @@ describe('Shard', function () {
17901790 ) ;
17911791 } ) ;
17921792 } ) ;
1793+
1794+ describe ( 'moveCollection' , function ( ) {
1795+ it ( 'calls serviceProvider.runCommandWithCheck' , async function ( ) {
1796+ await shard . moveCollection ( 'db.coll' , 'shard1' ) ;
1797+ expect ( serviceProvider . runCommandWithCheck ) . to . have . been . calledWith (
1798+ ADMIN_DB ,
1799+ {
1800+ moveCollection : 'db.coll' ,
1801+ toShard : 'shard1' ,
1802+ }
1803+ ) ;
1804+ } ) ;
1805+
1806+ it ( 'returns whatever serviceProvider.runCommandWithCheck returns' , async function ( ) {
1807+ const expectedResult = { ok : 1 } ;
1808+ serviceProvider . runCommandWithCheck . resolves ( expectedResult ) ;
1809+ const result = await shard . moveCollection ( 'db.coll' , 'shard1' ) ;
1810+ expect ( result ) . to . deep . equal ( expectedResult ) ;
1811+ } ) ;
1812+
1813+ it ( 'throws if serviceProvider.runCommandWithCheck rejects' , async function ( ) {
1814+ const expectedError = new Error ( ) ;
1815+ serviceProvider . runCommandWithCheck . rejects ( expectedError ) ;
1816+ const caughtError = await shard
1817+ . moveCollection ( 'db.coll' , 'shard1' )
1818+ . catch ( ( e ) => e ) ;
1819+ expect ( caughtError ) . to . equal ( expectedError ) ;
1820+ } ) ;
1821+ } ) ;
1822+
1823+ describe ( 'abortMoveCollection' , function ( ) {
1824+ it ( 'calls serviceProvider.runCommandWithCheck' , async function ( ) {
1825+ await shard . abortMoveCollection ( 'db.coll' ) ;
1826+ expect ( serviceProvider . runCommandWithCheck ) . to . have . been . calledWith (
1827+ ADMIN_DB ,
1828+ {
1829+ abortMoveCollection : 'db.coll' ,
1830+ }
1831+ ) ;
1832+ } ) ;
1833+
1834+ it ( 'returns whatever serviceProvider.runCommandWithCheck returns' , async function ( ) {
1835+ const expectedResult = { ok : 1 } ;
1836+ serviceProvider . runCommandWithCheck . resolves ( expectedResult ) ;
1837+ const result = await shard . abortMoveCollection ( 'db.coll' ) ;
1838+ expect ( result ) . to . deep . equal ( expectedResult ) ;
1839+ } ) ;
1840+
1841+ it ( 'throws if serviceProvider.runCommandWithCheck rejects' , async function ( ) {
1842+ const expectedError = new Error ( ) ;
1843+ serviceProvider . runCommandWithCheck . rejects ( expectedError ) ;
1844+ const caughtError = await shard
1845+ . abortMoveCollection ( 'db.coll' )
1846+ . catch ( ( e ) => e ) ;
1847+ expect ( caughtError ) . to . equal ( expectedError ) ;
1848+ } ) ;
1849+ } ) ;
1850+
1851+ describe ( 'unshardCollection' , function ( ) {
1852+ it ( 'calls serviceProvider.runCommandWithCheck' , async function ( ) {
1853+ await shard . unshardCollection ( 'db.coll' , 'shard1' ) ;
1854+ expect ( serviceProvider . runCommandWithCheck ) . to . have . been . calledWith (
1855+ ADMIN_DB ,
1856+ {
1857+ unshardCollection : 'db.coll' ,
1858+ toShard : 'shard1' ,
1859+ }
1860+ ) ;
1861+ } ) ;
1862+
1863+ it ( 'returns whatever serviceProvider.runCommandWithCheck returns' , async function ( ) {
1864+ const expectedResult = { ok : 1 } ;
1865+ serviceProvider . runCommandWithCheck . resolves ( expectedResult ) ;
1866+ const result = await shard . unshardCollection ( 'db.coll' , 'shard1' ) ;
1867+ expect ( result ) . to . deep . equal ( expectedResult ) ;
1868+ } ) ;
1869+
1870+ it ( 'throws if serviceProvider.runCommandWithCheck rejects' , async function ( ) {
1871+ const expectedError = new Error ( ) ;
1872+ serviceProvider . runCommandWithCheck . rejects ( expectedError ) ;
1873+ const caughtError = await shard
1874+ . unshardCollection ( 'db.coll' , 'shard1' )
1875+ . catch ( ( e ) => e ) ;
1876+ expect ( caughtError ) . to . equal ( expectedError ) ;
1877+ } ) ;
1878+ } ) ;
1879+
1880+ describe ( 'abortUnshardCollection' , function ( ) {
1881+ it ( 'calls serviceProvider.runCommandWithCheck' , async function ( ) {
1882+ await shard . abortUnshardCollection ( 'db.coll' ) ;
1883+ expect ( serviceProvider . runCommandWithCheck ) . to . have . been . calledWith (
1884+ ADMIN_DB ,
1885+ {
1886+ abortUnshardCollection : 'db.coll' ,
1887+ }
1888+ ) ;
1889+ } ) ;
1890+
1891+ it ( 'returns whatever serviceProvider.runCommandWithCheck returns' , async function ( ) {
1892+ const expectedResult = { ok : 1 } ;
1893+ serviceProvider . runCommandWithCheck . resolves ( expectedResult ) ;
1894+ const result = await shard . abortUnshardCollection ( 'db.coll' ) ;
1895+ expect ( result ) . to . deep . equal ( expectedResult ) ;
1896+ } ) ;
1897+
1898+ it ( 'throws if serviceProvider.runCommandWithCheck rejects' , async function ( ) {
1899+ const expectedError = new Error ( ) ;
1900+ serviceProvider . runCommandWithCheck . rejects ( expectedError ) ;
1901+ const caughtError = await shard
1902+ . abortUnshardCollection ( 'db.coll' )
1903+ . catch ( ( e ) => e ) ;
1904+ expect ( caughtError ) . to . equal ( expectedError ) ;
1905+ } ) ;
1906+ } ) ;
17931907 } ) ;
17941908
17951909 describe ( 'integration' , function ( ) {
0 commit comments