You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changed the way we match mappings in NameToInternalName, modified and added new testcases (#199)
* Changed the way we match mappings in NameToInternalName, modified and added tests.
* Verbose output when getting the InternalName in AddToSourceControl
* Add more negative test cases to the unit test
Co-authored-by: Sarmishta Velury <[email protected]>
Copy file name to clipboardExpand all lines: test/UnitTest/SourceControl/Git/NameToInternalNameTest.cls
+41-16Lines changed: 41 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -12,44 +12,66 @@ Property OldNamespaceTemp As %String;
12
12
MethodTestRegularClassNames()
13
13
{
14
14
// Regular class that exists
15
-
do $$$AssertEquals(##class(Utils).NameToInternalName("cls\SourceControl\Git\Utils.cls"),"SourceControl.Git.Utils.CLS")
15
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("cls\SourceControl\Git\Utils.cls"),"SourceControl.Git.Utils.CLS")
16
16
// Regular class that doesn't exist and we ignore non-existent classes
17
-
do $$$AssertEquals(##class(Utils).NameToInternalName("cls\SourceControl\Git\DoesNotExist.cls"),"")
17
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("cls\SourceControl\Git\DoesNotExist.cls"),"")
18
18
// Regular class that doesn't exist and we don't ignore non-existent classes
19
-
do $$$AssertEquals(##class(Utils).NameToInternalName("cls\SourceControl\Git\DoesNotExist.cls", 1, 0),"SourceControl.Git.DoesNotExist.CLS")
19
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("cls\SourceControl\Git\DoesNotExist.cls", 1, 0),"SourceControl.Git.DoesNotExist.CLS")
20
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("test\UnitTest\Git\DoesNotExist.cls", 1, 0),"UnitTest.Git.DoesNotExist.CLS")
21
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("foo\UnitTest\Foo\Git\DoesNotExist.cls", 1, 0),"UnitTest.Foo.Git.DoesNotExist.CLS")
22
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("foo\UnitTest\Foo\Git\DoesNotExist.foo", 1, 0),"UnitTest.Foo.Git.DoesNotExist.FOO")
20
23
}
21
24
22
25
MethodTestPercentClassNames()
23
26
{
24
27
// % class that exists but we ignore % classes
25
-
do $$$AssertEquals(##class(Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\Base.cls"),"")
28
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\Base.cls"),"")
26
29
// % class that exists and we don't ignore % classes
27
-
do $$$AssertEquals(##class(Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\Base.cls", 0),"%Studio.Extension.Base.CLS")
30
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\Base.cls", 0),"%Studio.Extension.Base.CLS")
28
31
// % class that doesn't exist and we ignore non-existent classes
29
-
do $$$AssertEquals(##class(Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\DoesNotExist.cls", 0),"")
32
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\DoesNotExist.cls", 0),"")
30
33
// % class that doesn't exist and we don't ignore non-existent classes
31
-
do $$$AssertEquals(##class(Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\DoesNotExist.cls", 0, 0),"%Studio.Extension.DoesNotExist.CLS")
34
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\DoesNotExist.cls", 0, 0),"%Studio.Extension.DoesNotExist.CLS")
32
35
}
33
36
34
37
MethodTestAbstractDocumentClassNames()
35
38
{
36
39
// %Studio.AbstractDocument type that exists
37
40
do##class(%RoutineMgr).Delete("test2.pivot.DFI")
38
-
do $$$AssertEquals(##class(Utils).NameToInternalName("test\_resources\dfi\test2.pivot.dfi"),"")
39
-
do $$$AssertStatusOK(##class(Utils).ImportItem("test2.pivot.DFI",1))
40
-
do $$$AssertEquals(##class(Utils).NameToInternalName("test\_resources\dfi\test2.pivot.dfi"),"test2.pivot.DFI")
41
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("test\_resources\dfi\test2.pivot.dfi"),"")
42
+
do $$$AssertStatusOK(##class(SourceControl.Git.Utils).ImportItem("test2.pivot.DFI",1))
43
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("test\_resources\dfi\test2.pivot.dfi"),"test2.pivot.DFI")
41
44
// %Studio.AbstractDocument type that does not exist and we ignore non-existent classes
42
-
do $$$AssertEquals(##class(Utils).NameToInternalName("test\_resources\dfi\DoesNotExist.dfi"),"")
45
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("test\_resources\dfi\DoesNotExist.dfi"),"")
43
46
// %Studio.AbstractDocument type that doesn't exist and we don't ignore non-existent classes
44
-
do $$$AssertEquals(##class(Utils).NameToInternalName("test\_resources\dfi\DoesNotExist.dfi", 1, 0),"DoesNotExist.DFI")
47
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("test\_resources\dfi\DoesNotExist.dfi", 1, 0),"DoesNotExist.DFI")
45
48
}
46
49
47
50
MethodTestStaticFileNames()
48
51
{
49
52
// Static file that shouldn't be on the server
50
-
do $$$AssertEquals(##class(Utils).NameToInternalName("git-webui\src\js\git-webui.js"),"")
51
-
// Static file that shouldn't be on the server but we don't ignore non-existent classes
52
-
do $$$AssertEquals(##class(Utils).NameToInternalName("git-webui\src\js\git-webui.js", 1, 0),"")
53
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("git-webui\src\js\git-webui.js"),"")
54
+
// Static file that shouldn't be on the server but we don't ignore non-existent classes (000 composite score)
55
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("git-webui\src\js\git-webui.js", 1, 0, 1),"")
56
+
}
57
+
58
+
MethodTestNegative()
59
+
{
60
+
// Based on composite scores
61
+
62
+
// 000 is covered in TestStaticFileNames()
63
+
// 001 and 002
64
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("barq\MyBarFile1.barq", 1, 0, 1),"")
65
+
// 010
66
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("bar\NotMyBarFile1.barq", 1, 0, 1),"")
67
+
// 011 and 012
68
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("bar\MyBarFile1.barq", 1, 0, 1),"")
69
+
// 100
70
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("barq\NotMyBarFile1.bar", 1, 0, 1),"")
71
+
// 101 and 102
72
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("barq\MyBarFile1.bar", 1, 0, 1),"")
73
+
// 110
74
+
do $$$AssertEquals(##class(SourceControl.Git.Utils).NameToInternalName("bar\NotMyBarFile1.bar", 1, 0, 1),"")
53
75
}
54
76
55
77
MethodOnBeforeAllTests() As%Status
@@ -61,6 +83,10 @@ Method OnBeforeAllTests() As %Status
0 commit comments