@@ -35,11 +35,13 @@ describe('install', () => {
3535 versionStub . get . withArgs ( 'box' ) . returns ( {
3636 version : '2022' ,
3737 exeUrl : 'https://example.com/installer.exe' ,
38- boxUrl : 'https://example.om/installer.box' ,
38+ boxUrl : 'https://example.com/installer.box' ,
39+ updateUrl : 'https://example.com/update.html' ,
3940 } ) ;
4041 versionStub . get . withArgs ( 'exe' ) . returns ( {
4142 version : '2019' ,
4243 exeUrl : 'https://example.com/setup.exe' ,
44+ updateUrl : 'https://example.com/update.exe' ,
4345 } ) ;
4446 versionStub . get . withArgs ( 'maxOs' ) . returns ( {
4547 version : '2017' ,
@@ -73,11 +75,13 @@ describe('install', () => {
7375 skipOsCheck : false ,
7476 nativeClientVersion : '' ,
7577 odbcVersion : '' ,
78+ installUpdates : false ,
7679 } ) ;
7780 utilsStub . getOsVersion . resolves ( 2022 ) ;
7881 utilsStub . gatherSummaryFiles . resolves ( [ ] ) ;
7982 utilsStub . downloadExeInstaller . resolves ( 'C:/tmp/exe/setup.exe' ) ;
8083 utilsStub . downloadBoxInstaller . resolves ( 'C:/tmp/box/setup.exe' ) ;
84+ utilsStub . downloadUpdateInstaller . resolves ( 'C:/tmp/exe/sqlupdate.exe' ) ;
8185 utilsStub . waitForDatabase . resolves ( 0 ) ;
8286 osStub = stub ( os ) ;
8387 osStub . platform . returns ( 'win32' ) ;
@@ -115,6 +119,7 @@ describe('install', () => {
115119 skipOsCheck : false ,
116120 nativeClientVersion : '' ,
117121 odbcVersion : '' ,
122+ installUpdates : false ,
118123 } ) ;
119124 try {
120125 await install ( ) ;
@@ -138,12 +143,71 @@ describe('install', () => {
138143 skipOsCheck : false ,
139144 nativeClientVersion : '' ,
140145 odbcVersion : '' ,
146+ installUpdates : false ,
141147 } ) ;
142148 await install ( ) ;
143149 expect ( execStub . exec ) . to . have . been . calledWith ( '"C:/tmp/exe/setup.exe"' , match . array , { windowsVerbatimArguments : true } ) ;
144150 } ) ;
151+ it ( 'downloads cumulative updates' , async ( ) => {
152+ utilsStub . gatherInputs . returns ( {
153+ version : 'exe' ,
154+ password : 'secret password' ,
155+ collation : 'SQL_Latin1_General_CP1_CI_AS' ,
156+ installArgs : [ ] ,
157+ wait : true ,
158+ skipOsCheck : false ,
159+ nativeClientVersion : '' ,
160+ odbcVersion : '' ,
161+ installUpdates : true ,
162+ } ) ;
163+ await install ( ) ;
164+ expect ( execStub . exec ) . to . have . been . calledWith ( '"C:/tmp/exe/setup.exe"' , match . array , { windowsVerbatimArguments : true } ) ;
165+ expect ( execStub . exec . firstCall . args [ 1 ] ) . to . contain . members ( [
166+ '/UPDATEENABLED=1' ,
167+ '/UpdateSource=C:/tmp/exe' ,
168+ ] ) ;
169+ } ) ;
170+ it ( 'uses cached updates if found' , async ( ) => {
171+ tcStub . find . withArgs ( 'sqlupdate' ) . returns ( 'C:/tool-cache/sql-update' ) ;
172+ utilsStub . gatherInputs . returns ( {
173+ version : 'exe' ,
174+ password : 'secret password' ,
175+ collation : 'SQL_Latin1_General_CP1_CI_AS' ,
176+ installArgs : [ ] ,
177+ wait : true ,
178+ skipOsCheck : false ,
179+ nativeClientVersion : '' ,
180+ odbcVersion : '' ,
181+ installUpdates : true ,
182+ } ) ;
183+ await install ( ) ;
184+ expect ( execStub . exec ) . to . have . been . calledWith ( '"C:/tmp/exe/setup.exe"' , match . array , { windowsVerbatimArguments : true } ) ;
185+ expect ( execStub . exec . firstCall . args [ 1 ] ) . to . contain . members ( [
186+ '/UPDATEENABLED=1' ,
187+ '/UpdateSource=C:/tool-cache/sql-update' ,
188+ ] ) ;
189+ } ) ;
190+ it ( 'skips cumulative updates if no update url' , async ( ) => {
191+ utilsStub . gatherInputs . returns ( {
192+ version : 'minOs' ,
193+ password : 'secret password' ,
194+ collation : 'SQL_Latin1_General_CP1_CI_AS' ,
195+ installArgs : [ ] ,
196+ wait : true ,
197+ skipOsCheck : false ,
198+ nativeClientVersion : '' ,
199+ odbcVersion : '' ,
200+ installUpdates : true ,
201+ } ) ;
202+ await install ( ) ;
203+ expect ( execStub . exec ) . to . have . been . calledWith ( '"C:/tmp/exe/setup.exe"' , match . array , { windowsVerbatimArguments : true } ) ;
204+ expect ( execStub . exec . firstCall . args [ 1 ] ) . to . not . contain . members ( [
205+ '/UPDATEENABLED=1' ,
206+ '/UpdateSource=C:/tmp/exe' ,
207+ ] ) ;
208+ } ) ;
145209 it ( 'uses cached tool if found' , async ( ) => {
146- tcStub . find . returns ( 'C:/tool-cache/sql-server' ) ;
210+ tcStub . find . withArgs ( 'sqlserver' ) . returns ( 'C:/tool-cache/sql-server' ) ;
147211 await install ( ) ;
148212 expect ( execStub . exec ) . to . have . been . calledWith ( '"C:/tool-cache/sql-server/setup.exe"' , match . array , { windowsVerbatimArguments : true } ) ;
149213 } ) ;
@@ -157,6 +221,7 @@ describe('install', () => {
157221 skipOsCheck : false ,
158222 nativeClientVersion : '' ,
159223 odbcVersion : '' ,
224+ installUpdates : false ,
160225 } ) ;
161226 try {
162227 await install ( ) ;
@@ -177,6 +242,7 @@ describe('install', () => {
177242 skipOsCheck : false ,
178243 nativeClientVersion : '' ,
179244 odbcVersion : '' ,
245+ installUpdates : false ,
180246 } ) ;
181247 try {
182248 await install ( ) ;
@@ -197,6 +263,7 @@ describe('install', () => {
197263 skipOsCheck : false ,
198264 nativeClientVersion : '' ,
199265 odbcVersion : '' ,
266+ installUpdates : false ,
200267 } ) ;
201268 try {
202269 await install ( ) ;
@@ -217,6 +284,7 @@ describe('install', () => {
217284 skipOsCheck : false ,
218285 nativeClientVersion : '' ,
219286 odbcVersion : '' ,
287+ installUpdates : false ,
220288 } ) ;
221289 await install ( ) ;
222290 expect ( execStub . exec ) . to . have . been . calledWith ( '"C:/tmp/exe/setup.exe"' , match . array , { windowsVerbatimArguments : true } ) ;
@@ -232,6 +300,7 @@ describe('install', () => {
232300 skipOsCheck : false ,
233301 nativeClientVersion : '' ,
234302 odbcVersion : '' ,
303+ installUpdates : false ,
235304 } ) ;
236305 await install ( ) ;
237306 expect ( execStub . exec ) . to . have . been . calledWith ( '"C:/tmp/exe/setup.exe"' , match . array , { windowsVerbatimArguments : true } ) ;
@@ -246,6 +315,7 @@ describe('install', () => {
246315 skipOsCheck : true ,
247316 nativeClientVersion : '' ,
248317 odbcVersion : '' ,
318+ installUpdates : false ,
249319 } ) ;
250320 await install ( ) ;
251321 expect ( execStub . exec ) . to . have . been . calledWith ( '"C:/tmp/exe/setup.exe"' , match . array , { windowsVerbatimArguments : true } ) ;
@@ -282,6 +352,7 @@ describe('install', () => {
282352 skipOsCheck : false ,
283353 nativeClientVersion : '' ,
284354 odbcVersion : '' ,
355+ installUpdates : false ,
285356 } ) ;
286357 const stubReadfile = stub ( fs , 'readFile' ) ;
287358 stubReadfile . resolves ( Buffer . from ( 'test data' ) ) ;
@@ -327,6 +398,7 @@ describe('install', () => {
327398 skipOsCheck : false ,
328399 nativeClientVersion : '11' ,
329400 odbcVersion : '' ,
401+ installUpdates : false ,
330402 } ) ;
331403 await install ( ) ;
332404 expect ( stubNc . default ) . to . have . been . calledOnceWith ( '11' ) ;
@@ -341,6 +413,7 @@ describe('install', () => {
341413 skipOsCheck : false ,
342414 nativeClientVersion : '11' ,
343415 odbcVersion : '18' ,
416+ installUpdates : false ,
344417 } ) ;
345418 await install ( ) ;
346419 expect ( stubNc . default ) . to . have . been . calledOnceWith ( '11' ) ;
0 commit comments