|
| 1 | +Class Test.PM.Integration.QualifiedModInfo Extends Test.PM.Integration.Base |
| 2 | +{ |
| 3 | + |
| 4 | +Parameter REPONAME = "simplest-module"; |
| 5 | + |
| 6 | +Property RepoPath As %String; |
| 7 | + |
| 8 | +Method OnBeforeAllTests() As %Status |
| 9 | +{ |
| 10 | + // Set up the repo path - use GetModuleDir utility |
| 11 | + set ..RepoPath = ..GetModuleDir(..#REPONAME) |
| 12 | + |
| 13 | + // Create filesystem repo pointing to test data |
| 14 | + set sc = ##class(%IPM.Main).Shell("repo -n "_..#REPONAME_" -fs -path "_..RepoPath) |
| 15 | + do $$$AssertStatusOK(sc,"Created"_..#REPONAME_"repo successfully.") |
| 16 | + quit sc |
| 17 | +} |
| 18 | + |
| 19 | +Method OnAfterAllTests() As %Status |
| 20 | +{ |
| 21 | + // Remove test repository |
| 22 | + set sc = ##class(%IPM.Main).Shell("repo -delete -name "_..#REPONAME) |
| 23 | + do $$$AssertStatusOK(sc,"Deleted "_..#REPONAME_"repo successfully.") |
| 24 | + quit sc |
| 25 | +} |
| 26 | + |
| 27 | +/// SearchRepositoriesForModule should return a module reference |
| 28 | +/// will AllVersions set to all three versions of the module when no version specified in search criteria |
| 29 | +Method TestSearchModuleNoVersionSpecified() |
| 30 | +{ |
| 31 | + // Set searchCriteria |
| 32 | + set searchCriteria = ##class(%IPM.Repo.SearchCriteria).%New() |
| 33 | + set searchCriteria.Name = ..#REPONAME |
| 34 | + set searchCriteria.AllVersions = 1 |
| 35 | + |
| 36 | + // Search repos |
| 37 | + set sc = ##class(%IPM.Repo.Utils).SearchRepositoriesForModule(searchCriteria, .resultList) |
| 38 | + do $$$AssertStatusOK(sc, "SearchRepositoriesForModule call was successful.") |
| 39 | + do $$$AssertTrue((resultList.Count() = 1), "Found module.") |
| 40 | + |
| 41 | + // Get the first module reference |
| 42 | + set moduleReference = resultList.GetAt(1) |
| 43 | + |
| 44 | + // Make sure AllVersions is set and contains all three versions of the module |
| 45 | + set versionsString = moduleReference.AllVersions |
| 46 | + do $$$AssertTrue((versionsString = "3.0.0, 2.0.0, 1.0.0"), "AllVersions contains all versions of the module.") |
| 47 | + |
| 48 | + // Make sure VersionString is set to the latest version of the module |
| 49 | + do $$$AssertTrue((moduleReference.VersionString = "3.0.0"), "VersionString is set to the latest version of the module.") |
| 50 | +} |
| 51 | + |
| 52 | +/// SearchRepositoriesForModule should return a module reference |
| 53 | +/// will AllVersions set to all versions of the module that match the version expression in search criteria |
| 54 | +Method TestSearchModuleVersionSpecified() |
| 55 | +{ |
| 56 | + // Set searchCriteria |
| 57 | + set searchCriteria = ##class(%IPM.Repo.SearchCriteria).%New() |
| 58 | + set searchCriteria.Name = ..#REPONAME |
| 59 | + set searchCriteria.AllVersions = 1 |
| 60 | + set searchCriteria.VersionExpression = "<3.0.0" |
| 61 | + |
| 62 | + // Search repos |
| 63 | + set sc = ##class(%IPM.Repo.Utils).SearchRepositoriesForModule(searchCriteria, .resultList) |
| 64 | + do $$$AssertStatusOK(sc, "SearchRepositoriesForModule call was successful.") |
| 65 | + do $$$AssertTrue((resultList.Count() = 1), "Found module.") |
| 66 | + |
| 67 | + // Get the first module reference |
| 68 | + set moduleReference = resultList.GetAt(1) |
| 69 | + |
| 70 | + // Make sure AllVersions is set and contains all three versions of the module |
| 71 | + set versionsString = moduleReference.AllVersions |
| 72 | + do $$$AssertTrue((versionsString = "2.0.0, 1.0.0"), "AllVersions contains all matching versions of the module.") |
| 73 | + |
| 74 | + // Make sure VersionString is set to specified version of the module |
| 75 | + do $$$AssertTrue((moduleReference.VersionString = "2.0.0"), "VersionString is set to the specified version of the module.") |
| 76 | +} |
| 77 | + |
| 78 | +} |
0 commit comments