mercurial/HGTests.st
changeset 403 237ed0ed6c49
parent 395 fc0607653d8a
child 444 8987b87a562a
--- a/mercurial/HGTests.st	Wed Mar 19 23:19:22 2014 +0000
+++ b/mercurial/HGTests.st	Fri Mar 21 11:23:30 2014 +0000
@@ -95,6 +95,235 @@
     "Modified: / 22-11-2012 / 11:42:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGTests methodsFor:'tests - bookmarks'!
+
+test_bookmarks_01a
+    "
+    Simply set bookmark
+    "
+
+    | repo wc|
+
+    repo := self repositoryNamed:'test_repo_01'.
+    wc := repo workingCopy.
+    self assert: (repo @ 4) bookmarks isEmpty.
+
+    wc bookmarkAs: 'test_bookmarks_01'.
+
+    self assert: (repo @ 4) bookmarks size == 1.
+    self assert: (repo @ 4) bookmarks anElement name = 'test_bookmarks_01'.
+    self assert: (repo @ 4) bookmarks anElement isActive.
+
+    self assert: wc bookmarks size == 1.
+    self assert: wc bookmarks anElement name = 'test_bookmarks_01'.
+    self assert: wc bookmarks anElement isActive.
+
+    "Created: / 20-03-2014 / 09:11:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 20-03-2014 / 17:30:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_bookmarks_01b
+    "
+    Simply set bookmark
+    "
+
+    | repo wc|
+
+    repo := self repositoryNamed:'test_repo_01'.
+    wc := repo workingCopy.
+    self assert: (repo @ 4) bookmarks isEmpty.
+
+    (repo @ 4) bookmarkAs: 'test_bookmarks_01'.
+
+    self assert: (repo @ 4) bookmarks size == 1.
+    self assert: (repo @ 4) bookmarks anElement name = 'test_bookmarks_01'.
+    "/ Bookmark is not active as it was created on changeset not on
+    "/ working copy.
+    self assert: (repo @ 4) bookmarks anElement isActive not.
+
+    self assert: wc bookmarks size == 1.
+    self assert: wc bookmarks anElement name = 'test_bookmarks_01'.
+    "/ Bookmark is not active as it was created on changeset not on
+    "/ working copy.
+    self assert: wc bookmarks anElement isActive not.
+
+    "Created: / 20-03-2014 / 09:11:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 20-03-2014 / 18:46:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_bookmarks_01c
+    "
+    Simply set bookmark
+    "
+
+    | repo wc|
+
+    repo := self repositoryNamed:'test_repo_01'.
+    wc := repo workingCopy.
+    self assert: (repo @ 4) bookmarks isEmpty.
+
+    (repo @ 3) bookmarkAs: 'test_bookmarks_01'.
+
+    self assert: (repo @ 3) bookmarks size == 1.
+    self assert: (repo @ 3) bookmarks anElement name = 'test_bookmarks_01'.
+    self assert: (repo @ 3) bookmarks anElement isActive not.
+
+    self assert: (repo @ 4) bookmarks isEmpty.
+    self assert: wc bookmarks isEmpty.
+
+    "Created: / 20-03-2014 / 09:12:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 20-03-2014 / 17:30:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_bookmarks_02
+    "
+    Set the same bookmark twice
+    "
+
+    | repo wc|
+
+    repo := self repositoryNamed:'test_repo_01'.
+    wc := repo workingCopy.
+    self assert: (repo @ 4) bookmarks isEmpty.
+
+    (repo @ 4) bookmarkAs: 'test_bookmarks_02'.
+    self should: [ (repo @ 4) bookmarkAs: 'test_bookmarks_02' ] raise: HGBookmarkError.
+
+    "Created: / 20-03-2014 / 09:21:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_bookmarks_03a
+    "
+    Set two bookmarks on checked-out changeset, 
+    check that last one is active.
+    "
+
+    | repo wc|
+
+    repo := self repositoryNamed:'test_repo_01'.
+    wc := repo workingCopy.
+    self assert: (repo @ 4) bookmarks isEmpty.
+    "
+     UserPreferences fileBrowserClass openOn: repo pathName asFilename.
+    "   
+    wc bookmarkAs: 'test_bookmarks_03 A'.
+    self assert: (repo @ 4) bookmarks size == 1.
+    self assert: (repo @ 4) bookmarks anElement isActive.    
+
+    wc bookmarkAs: 'test_bookmarks_03 B'.
+
+    self assert: (repo @ 4) bookmarks size == 2.
+    self assert: ((repo @ 4) bookmarks detect:[:e | e name = 'test_bookmarks_03 A' ]) isActive not.
+    self assert: ((repo @ 4) bookmarks detect:[:e | e name = 'test_bookmarks_03 B' ]) isActive.
+
+    "Created: / 20-03-2014 / 09:23:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 20-03-2014 / 18:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 20-03-2014 / 22:43:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_bookmarks_03b
+    "
+    Set two bookmarks on non-checked changeset,
+    check none is active.
+    "
+
+    | repo wc|
+
+    repo := self repositoryNamed:'test_repo_01'.
+    wc := repo workingCopy.
+    self assert: (repo @ 3) bookmarks isEmpty.
+
+    (repo @ 3) bookmarkAs: 'test_bookmarks_03 A'.
+
+    self assert: (repo @ 3) bookmarks size == 1.
+    self assert: (repo @ 3) bookmarks anElement isActive not.    
+
+    (repo @ 3) bookmarkAs: 'test_bookmarks_03 B'.
+    self assert: (repo @ 3) bookmarks size == 2.
+    self assert: ((repo @ 3) bookmarks detect:[:e | e name = 'test_bookmarks_03 A' ]) isActive not.
+    self assert: ((repo @ 3) bookmarks detect:[:e | e name = 'test_bookmarks_03 B' ]) isActive not.
+
+    "Created: / 20-03-2014 / 09:24:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-03-2014 / 01:05:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_bookmarks_04a
+    "
+    Simply set & remove bookmark
+    "
+
+    | repo cs |
+
+    repo := self repositoryNamed:'test_repo_01'.
+    cs := repo @ 4.
+    self assert: cs bookmarks isEmpty.
+
+    cs bookmarkAs: 'test_bookmarks_04a'.
+
+    self assert: cs bookmarks size == 1.
+    self assert: cs bookmarks anElement name = 'test_bookmarks_04a'.
+    self assert: cs bookmarks anElement isActive not.
+
+    cs bookmarks anElement remove.
+
+    self assert: (repo @ 4) bookmarks isEmpty.
+
+    "Created: / 20-03-2014 / 09:29:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-03-2014 / 01:06:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_bookmarks_04b
+    "
+    Simply set & remove bookmark
+    "
+
+    | repo cs |
+
+    repo := self repositoryNamed:'test_repo_01'.
+    cs := repo @ 3.
+    self assert: cs bookmarks isEmpty.
+
+    cs bookmarkAs: 'test_bookmarks_04b'.
+
+    self assert: cs bookmarks size == 1.
+    self assert: cs bookmarks anElement name = 'test_bookmarks_04b'.
+    self assert: cs bookmarks anElement isActive not.
+
+    cs bookmarks anElement remove.
+
+    self assert: cs bookmarks isEmpty.
+
+    "Created: / 20-03-2014 / 09:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-03-2014 / 01:06:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_bookmarks_04c
+    "
+    Simply set two bookmarks & remove one bookmark
+    "
+
+    | repo cs wc |
+
+    repo := self repositoryNamed:'test_repo_01'.
+    cs := repo @ 4.
+    wc := repo workingCopy.
+    self assert: cs bookmarks isEmpty.
+
+    wc bookmarkAs: 'test_bookmarks_04b A'.
+    wc bookmarkAs: 'test_bookmarks_04b B'.
+
+    self assert: cs bookmarks size == 2.
+
+    (cs bookmarks detect:[:e | e name = 'test_bookmarks_04b A']) remove.
+
+    self assert: cs bookmarks size == 1.
+    self assert: cs bookmarks anElement name = 'test_bookmarks_04b B'.
+    self assert: cs bookmarks anElement isActive.
+
+    "Created: / 20-03-2014 / 09:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-03-2014 / 01:25:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGTests methodsFor:'tests - branches'!
 
 test_branches_01
@@ -616,6 +845,43 @@
 
     "Created: / 01-02-2013 / 14:46:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 06-02-2013 / 10:22:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_05
+    "
+    Bookmark changeset and commit. Make sure bookmark moved.
+    "
+
+    | repo wc|
+
+    repo := self repositoryNamed:'test_repo_01'.
+    wc := repo workingCopy.
+    self assert: (repo @ 4) bookmarks isEmpty.
+
+    "/ Bookmark currently checked-out working copy.
+    wc bookmarkAs: 'test_commit_05'.
+
+    self assert: (repo @ 4) bookmarks size == 1.
+    self assert: (repo @ 4) bookmarks anElement name = 'test_commit_05'.
+    self assert: (repo @ 4) bookmarks anElement isActive.
+
+
+    ( wc / 'f1.txt' ) writingFileDo:[:s | s nextPutAll:'modified from test_commit_04 2'. ].
+    wc commit: 'test_commit_05 1'.
+
+    "/ Bookmark should move...
+    self assert: (repo @ 4) bookmarks isEmpty.
+    self assert: (repo @ 5) bookmarks size == 1.
+    self assert: (repo @ 5) bookmarks anElement name = 'test_commit_05'.
+    self assert: (repo @ 5) bookmarks anElement isActive.
+
+
+
+    "
+     UserPreferences fileBrowserClass openOn: repo directory.
+    "
+
+    "Created: / 20-03-2014 / 08:53:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGTests methodsFor:'tests - mercurial'!