Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 integration test cleanup #600

Draft
wants to merge 1 commit into
base: v1
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions tests/integration_tests/Test/PM/Integration/Base.cls
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Include %IPM.Common

Class Test.PM.Integration.Base Extends %UnitTest.TestCase
{

Expand All @@ -13,11 +15,18 @@ Property ClientNSCreated As %Boolean [ InitialExpression = 0 ];

Property RegistryAdded As %Boolean [ InitialExpression = 0 ];

Property PreexistingModules As %Library.ArrayOfDataTypes;

Property OriginalNamespace As %String;

// Multidimensional doesn't work well

Method Setup() As %Status
{
Set tSC = $$$OK
Try {
New $Namespace
Set tSC = $$$ADDSC(tSC, ..RecordOldModules())
do $$$AssertStatusOK(##class(%IPM.Repo.Filesystem.Definition).%DeleteExtent())
do $$$AssertStatusOK(##class(%IPM.Repo.Remote.Definition).%DeleteExtent())

Expand Down Expand Up @@ -69,12 +78,53 @@ Method TearDown() As %Status
if ..RegistryAdded {
Do $$$AssertStatusOK(##class(%IPM.Repo.Definition).ServerDefinitionKeyDelete(..#REGISTRYNAME))
}
Set tSC = $$$ADDSC(tSC, ..DeleteNewModules())
} Catch e {
Set tSC = e.AsStatus()
}
Quit tSC
}

Method DeleteNewModules() As %Status
{
Set sc = $$$OK
Try {
Do ##class(%IPM.Main).GetListModules(..OriginalNamespace, "", .list)
Zwrite "", "DeleteNewModules", $classname(), list
For i = 1:1:list {
Set modName = $ListGet(list(i))
// $$$IPMModuleName should be already in PreexistingModules, but just in case
If modName = $$$IPMModuleName {
Continue
}
If ..PreexistingModules.IsDefined(modName) {
Set sc = $$$ADDSC(sc, ##class(%IPM.Main).Shell("uninstall "_modName))
}
}
} Catch e {
Set sc = $$$ADDSC(sc, e.AsStatus())
}
Return sc
}

/// OnBeforeAllTests is not compatible with $$$AssertSkipped
Method RecordOldModules() As %Status
{
Try {
Set ..OriginalNamespace = $Namespace
Do ##class(%IPM.Main).GetListModules($Namespace, "", .list)
Zwrite "", "RecordOldModules", $classname(), list
Do ..PreexistingModules.Clear()
For i = 1:1:list {
Set modName = $ListGet(list(i))
Do ..PreexistingModules.SetAt("", modName)
}
} Catch e {
Return e.AsStatus()
}
Return $$$OK
}

ClassMethod ReadXDataToModule(pNamespace As %String = {$NAMESPACE}, pXDataName As %String, ByRef pModule As %IPM.Storage.Module) As %Status
{
New $Namespace
Expand Down