|
1 | | -Class UnitTest.SourceControl.Git.ImportAll Extends %UnitTest.TestCase |
| 1 | +Class UnitTest.SourceControl.Git.ImportAll Extends UnitTest.SourceControl.Git.AbstractTest |
2 | 2 | { |
3 | 3 |
|
4 | | -Property InitialExtension As %String [ InitialExpression = {##class(%Studio.SourceControl.Interface).SourceControlClassGet()} ]; |
5 | | - |
6 | | -Property SourceControlGlobal [ MultiDimensional ]; |
| 4 | +Property WebAppPath As %String; |
7 | 5 |
|
8 | 6 | Method %OnNew(initvalue) As %Status |
9 | 7 | { |
10 | | - Merge ..SourceControlGlobal = ^SYS("SourceControl") |
| 8 | + $$$QuitOnError(##super(initvalue)) |
11 | 9 | Kill ^SYS("SourceControl") |
| 10 | + /// add mappings for MAC and CSP |
12 | 11 | Set settings = ##class(SourceControl.Git.Settings).%New() |
13 | | - Set settings.namespaceTemp = ##class(%Library.File).TempFilename()_"dir" |
14 | 12 | Set settings.Mappings("MAC","*")="rtn/" |
| 13 | + Set settings.Mappings("/CSP/","/csp/git/unittest/xsl")="csp/git/unittest/xsl" |
15 | 14 | $$$ThrowOnError(settings.%Save()) |
16 | | - Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet("SourceControl.Git.Extension") |
17 | | - Quit ##super(initvalue) |
| 15 | + set ..WebAppPath = ##class(%File).TempFilename()_"d" |
| 16 | + do ##class(%File).CreateDirectoryChain(..WebAppPath) |
| 17 | + do ..CreateTestWebApp("/csp/git/unittest/xsl", ..WebAppPath) |
| 18 | + return $$$OK |
| 19 | +} |
| 20 | + |
| 21 | +ClassMethod CreateTestWebApp(name, path) |
| 22 | +{ |
| 23 | + new $namespace |
| 24 | + set $namespace = "%SYS" |
| 25 | + kill props |
| 26 | + set props("Path") = path |
| 27 | + if '##class(Security.Applications).Exists(name) { |
| 28 | + $$$ThrowOnError(##class(Security.Applications).Create(name, .props)) |
| 29 | + } else { |
| 30 | + $$$ThrowOnError(##class(Security.Applications).Create(name, .props)) |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +ClassMethod DeleteTestWebApp(name) |
| 35 | +{ |
| 36 | + |
| 37 | + new $namespace |
| 38 | + set $namespace = "%SYS" |
| 39 | + if ##class(Security.Applications).Exists(name) { |
| 40 | + $$$ThrowOnError(##class(Security.Applications).Delete(name)) |
| 41 | + } |
18 | 42 | } |
19 | 43 |
|
20 | 44 | Method %OnClose() As %Status [ Private, ServerOnly = 1 ] |
21 | 45 | { |
22 | | - Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet(..InitialExtension) |
23 | | - Kill ^SYS("SourceControl") |
24 | | - Merge ^SYS("SourceControl") = ..SourceControlGlobal |
25 | | - Quit $$$OK |
| 46 | + do ..DeleteTestWebApp("/csp/git/unittest/xsl") |
| 47 | + do ##class(%File).RemoveDirectoryTree(..WebAppPath) |
| 48 | + quit ##super() |
26 | 49 | } |
27 | 50 |
|
28 | 51 | Method TestImportAll() |
29 | 52 | { |
30 | 53 | do ..CreateTestRoutine() |
31 | 54 | $$$ThrowOnError(##class(SourceControl.Git.Utils).AddToSourceControl("test.mac")) |
32 | 55 | do ..CreateStrayFileInRtn() |
| 56 | + do ..WriteFile(##class(SourceControl.Git.Settings).%New().namespaceTemp_"csp/git/unittest/xsl/test.xsl", "<?xml version=""1.0"" encoding=""UTF-8""?> <xsl:stylesheet version=""1.0""></xsl:stylesheet>") |
33 | 57 | $$$ThrowOnError(##class(%Routine).Delete("test.mac")) |
| 58 | + do ##class(%RoutineMgr).Delete("/csp/git/unittest/xsl/test.xsl") |
34 | 59 | $$$ThrowOnError(##class(SourceControl.Git.Utils).ImportAll(1)) |
35 | 60 | do $$$AssertTrue(##class(%Routine).Exists("test.mac")) |
| 61 | + do $$$AssertTrue(##class(%RoutineMgr).Exists("/csp/git/unittest/xsl/test.xsl")) |
| 62 | + do $$$AssertFilesSame(##class(SourceControl.Git.Settings).%New().namespaceTemp_"csp/git/unittest/xsl/test.xsl", ..WebAppPath_"/test.xsl") |
36 | 63 | } |
37 | 64 |
|
38 | 65 | Method CreateTestRoutine() |
|
0 commit comments