|
| 1 | +Class UnitTest.SourceControl.Git.ImportAll Extends %UnitTest.TestCase |
| 2 | +{ |
| 3 | + |
| 4 | +Property InitialExtension As %String [ InitialExpression = {##class(%Studio.SourceControl.Interface).SourceControlClassGet()} ]; |
| 5 | + |
| 6 | +Property SourceControlGlobal [ MultiDimensional ]; |
| 7 | + |
| 8 | +Method %OnNew(initvalue) As %Status |
| 9 | +{ |
| 10 | + Merge ..SourceControlGlobal = ^SYS("SourceControl") |
| 11 | + Kill ^SYS("SourceControl") |
| 12 | + Set settings = ##class(SourceControl.Git.Settings).%New() |
| 13 | + Set settings.namespaceTemp = ##class(%Library.File).TempFilename()_"dir" |
| 14 | + Set settings.Mappings("MAC","*")="rtn/" |
| 15 | + $$$ThrowOnError(settings.%Save()) |
| 16 | + Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet("SourceControl.Git.Extension") |
| 17 | + Quit ##super(initvalue) |
| 18 | +} |
| 19 | + |
| 20 | +Method %OnClose() As %Status [ Private, ServerOnly = 1 ] |
| 21 | +{ |
| 22 | + Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet(..InitialExtension) |
| 23 | + Kill ^SYS("SourceControl") |
| 24 | + Merge ^SYS("SourceControl") = ..SourceControlGlobal |
| 25 | + Quit $$$OK |
| 26 | +} |
| 27 | + |
| 28 | +Method TestImportAll() |
| 29 | +{ |
| 30 | + do ..CreateTestRoutine() |
| 31 | + $$$ThrowOnError(##class(SourceControl.Git.Utils).AddToSourceControl("test.mac")) |
| 32 | + do ..CreateStrayFileInRtn() |
| 33 | + $$$ThrowOnError(##class(%Routine).Delete("test.mac")) |
| 34 | + $$$ThrowOnError(##class(SourceControl.Git.Utils).ImportAll(1)) |
| 35 | + do $$$AssertTrue(##class(%Routine).Exists("test.mac")) |
| 36 | +} |
| 37 | + |
| 38 | +Method CreateTestRoutine() |
| 39 | +{ |
| 40 | + if '##class(%Routine).Exists("test.mac") { |
| 41 | + set r = ##class(%Routine).%New("test.mac") |
| 42 | + do r.WriteLine(" write 22,!") |
| 43 | + do r.Save() |
| 44 | + do r.Compile() |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +/// creates a text file in the routines directory that is not really a routine |
| 49 | +Method CreateStrayFileInRtn() |
| 50 | +{ |
| 51 | + set fileStream = ##class(%Stream.FileCharacter).%OpenId( |
| 52 | + ##class(%File).NormalizeFilename( |
| 53 | + "test.txt", |
| 54 | + ##class(%File).GetDirectory(##class(SourceControl.Git.Utils).FullExternalName("test.mac"))) |
| 55 | + ,,.sc) |
| 56 | + $$$ThrowOnError(sc) |
| 57 | + $$$ThrowOnError(fileStream.Write("hello world!")) |
| 58 | + $$$ThrowOnError(fileStream.%Save()) |
| 59 | +} |
| 60 | + |
| 61 | +} |
0 commit comments