@@ -127,8 +127,7 @@ Method Test04Module2Dependencies1Transient()
127127/// Edge cases below:
128128/// All repository types
129129/// Uses Module G
130- /// TODO: Update lock-mod-oras: Created lock file with mods-other-repos filesystem repo instead of oras + remote repo
131- Method Test05ModuleDependenciesAllRepositoryTypes ()
130+ Method Test05AllRepositoryTypes ()
132131{
133132 set sc = $$$OK
134133 try {
@@ -165,41 +164,8 @@ Method Test05ModuleDependenciesAllRepositoryTypes()
165164 do $$$AssertStatusOK(sc ," Removed lock-file-other-repos repo successfully." )
166165
167166 // Now that modules and repositories are set up, do the actual test
168- set moduleName = " lock-mod-oras"
169- do ..AssertInstallCreatesLockFileAsExpected (moduleName )
170-
171- // Go back to the initial state by uninstalling the module, dependencies, and repositories used for this test
172- do ##class (%IPM.Main ).Shell (" uninstall -r " _moduleName )
173- do $$$AssertStatusOK(sc , " Uninstalled " _moduleName _" and dependencies at the end of the test" )
174-
175-
176- // Now test installing from a lock file from a module in a remote repository
177- set moduleName = " lock-mod-remote"
178-
179- // TODO: Replace this with zpm "ci" once implemented
180- set sc = ##class (%IPM.Main ).Shell (" install " _remoteRepo _" /" _moduleName )
181- do $$$AssertStatusOK(sc , " Installed " _moduleName _" via the laock file successfully" )
182-
183- // Confirm that module and dependency classes were loaded correctly
184- do $classmethod (" LockModRemote.Class1" , " MethodA" )
185-
186-
187- // Now test installing from a lock file from a module in an oras repository
188- set moduleName = " lock-mod-oras"
189-
190- // TODO: Replace this with zpm "ci" once implemented
191- set sc = ##class (%IPM.Main ).Shell (" install " _orasRepo _" /" _moduleName )
192- do $$$AssertStatusOK(sc , " Installed " _moduleName _" via the laock file successfully" )
193-
194- // Confirm that module and dependency classes were loaded correctly
195- do $classmethod (" LockModORAS.Class1" , " MethodA" )
196-
197-
198-
199-
200-
201-
202-
167+ do ..ExecuteGenericLockFileTest (remoteMod , " LockModRemote.Class1" )
168+ do ..ExecuteGenericLockFileTest (orasMod , " LockModORAS.Class1" )
203169
204170 do ##class (%IPM.Main ).Shell (" repo -delete -name " _remoteRepo )
205171 do $$$AssertStatusOK(sc , " Removed " _remoteRepo _" at the end of the test" )
@@ -236,11 +202,11 @@ Method Test06ModuleMultipleVersions()
236202 do $$$AssertStatusOK(sc , " Uninstalled " _moduleName )
237203
238204 // Install module from lock file
239- // TODO: Replace this with zpm "ci" once implemented
240- set sc = ##class ( %IPM.Main ). Shell ( " install " _ moduleName )
205+ set sc = ##class ( %IPM.Main ). Shell ( " ci " _ moduleName )
206+ do $$$AssertStatusOK( sc , " Able to install " _ moduleName _ " v " _ latestVersion _ " from the lock file " )
241207
242208 // Confirm classes and dependencies get installed as well
243- do $classmethod (" LockModH.Class1" , " MethodA " )
209+ do $classmethod (" LockModH.Class1" , " MethodB " )
244210
245211 // Uninstall module before testing with other version
246212 set sc = ##class (%IPM.Main ).Shell (" uninstall -r " _moduleName )
@@ -267,8 +233,8 @@ Method Test06ModuleMultipleVersions()
267233 do $$$AssertStatusOK(sc , " Uninstalled " _moduleName )
268234
269235 // Install module from lock file
270- // TODO: Replace this with zpm "ci" once implemented
271- set sc = ##class ( %IPM.Main ). Shell ( " install " _ moduleName )
236+ set sc = ##class ( %IPM.Main ). Shell ( " ci " _ moduleName _ " " _ olderVersion )
237+ do $$$AssertStatusOK( sc , " Able to install " _ moduleName _ " v " _ olderVersion _ " from the lock file " )
272238
273239 // Confirm classes and dependencies get installed as well
274240 do $classmethod (" LockModH.Class1" , " MethodA" )
@@ -278,10 +244,10 @@ Method Test06ModuleMultipleVersions()
278244}
279245
280246/// Module with no pre-existing lock file
281- /// - [TODO, with "ci" command] zpm "ci" should fail due to not being able to locate the lock file
282247/// - Test creation of a lock file, for a module that did not already have one.
283248/// - Differs from other tests which overwrite pre-existing lock files
284249/// - Both cases SHOULD be functionally equivalent
250+ /// - zpm "ci" should fail due to not being able to locate the lock file
285251/// Uses Module I
286252Method Test07ModuleNoLockFile ()
287253{
@@ -302,22 +268,28 @@ Method Test07ModuleNoLockFile()
302268 set sc = ##class (%IPM.Main ).Shell (" uninstall -r " _moduleName )
303269 do $$$AssertStatusOK(sc , " Uninstalled " _moduleName )
304270
305- // TODO: This should fail due to no lock file
306- //Install module from lock file
307- // do ..AssertInstallFromLockFileAsExpected(moduleName )
271+ // This should fail due to no lock file
272+ set sc = ##class ( %IPM.Main ). Shell ( " ci " _ moduleName )
273+ do $$$AssertStatusNotOK( sc , " zpm " " ci " " fails on module " _ moduleName _ " due to not having a lock file " )
308274 } catch e {
309275 do $$$AssertStatusOK(e .AsStatus ()," An exception occurred in Test07ModuleNoLockFile." )
310276 }
311277}
312278
279+ /// TODO: This succeeds, compiling modules doesn't see dependency issues and by the time
280+ /// we call LockModJ.Class1::MethodA() all dependencies are loaded so no issues there.
281+ /// - Is that okay?
282+ /// - I'm inclined to say yes. Dependencies out of order isn't too realistic a use case
283+ /// anyways so maybe delete this case altogether?
313284/// Try install on a lock file that lists dependencies out of order
314285/// Uses Module J
315286Method Test08ModuleDependenciesOutOfOrder ()
316287{
317288 set moduleName = ..#ModuleJ
318289
319- // TODO: Replace this with zpm "ci" once implemented
320- //set sc = ##class(%IPM.Main).Shell("install "_moduleName)
290+ zpm " install -lock " _moduleName
291+
292+ //set sc = ##class(%IPM.Main).Shell("ci "_moduleName)
321293 //do $$$AssertStatusNotOK(sc, "Installing from lock file with dependencies listed out of order fails")
322294}
323295
@@ -349,7 +321,9 @@ Method Test10ComplexNestedDependencies()
349321/// 3. Uninstall the module (and dependencies)
350322/// 4. Install from lock file via zpm "ci"
351323/// 5. Call method in installed module (which in turn calls dependency methods) to confirm "ci" loads all modules correctly
352- Method ExecuteGenericLockFileTest (moduleName As %String )
324+ Method ExecuteGenericLockFileTest (
325+ moduleName As %String ,
326+ className As %String = " " )
353327{
354328 // Install and create lock file for module
355329 do ..AssertInstallCreatesLockFileAsExpected (moduleName )
@@ -359,7 +333,7 @@ Method ExecuteGenericLockFileTest(moduleName As %String)
359333 do $$$AssertStatusOK(sc , " Uninstalled " _moduleName )
360334
361335 // Install module from lock file
362- do ..AssertInstallFromLockFileAsExpected (moduleName )
336+ do ..AssertInstallFromLockFileAsExpected (moduleName , className )
363337}
364338
365339/// Base cases of creating a lock file upon install of a module
@@ -390,8 +364,6 @@ ClassMethod AreLockFilesEqual(
390364 try {
391365 set actualLockFileContents = ##class (%DynamicAbstractObject ).%FromJSONFile (actualLockFilePath )
392366 set expectedLockFileContents = ##class (%DynamicAbstractObject ).%FromJSONFile (expectedLockFilePath )
393- zwrite actualLockFileContents
394- zwrite expectedLockFileContents
395367 return actualLockFileContents .%ToJSON () = expectedLockFileContents .%ToJSON ()
396368 } catch (ex ) {
397369 // Should error if we fail to open either the actual or expected file
@@ -400,16 +372,20 @@ ClassMethod AreLockFilesEqual(
400372}
401373
402374/// Base case of installing a module from a lock file and confirming everything gets loaded as expected
403- Method AssertInstallFromLockFileAsExpected (moduleName As %String )
375+ Method AssertInstallFromLockFileAsExpected (
376+ moduleName As %String ,
377+ className As %String = " " )
404378{
405- // TODO: Replace this with zpm "ci" once implemented
406- set sc = ##class ( %IPM.Main ). Shell ( " install " _ moduleName )
379+ set sc = ##class ( %IPM.Main ). Shell ( " ci " _ moduleName )
380+ do $$$AssertStatusOK( sc , " Installed " _ moduleName _ " via the lock file successfully " )
407381
408382 set sc = $$$OK
409383 try {
410- // Letter of the module is in the 10th place: "lock-mod-x-..."
411- set packageLetter = $zconvert ($extract (moduleName , 10 ), " u" )
412- set className = " LockMod" _packageLetter _" .Class1"
384+ if (className = " " ) {
385+ // Letter of the module is in the 10th place: "lock-mod-x-..."
386+ set packageLetter = $zconvert ($extract (moduleName , 10 ), " u" )
387+ set className = " LockMod" _packageLetter _" .Class1"
388+ }
413389 do $classmethod (className , " MethodA" )
414390 } catch (ex ) {
415391 set sc = ex .AsStatus ()
0 commit comments