scm: mercurial: add adapter entry test (#14361)

git-svn-id: http://svn.redmine.org/redmine/trunk@12756 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2014-02-02 04:43:17 +00:00
parent 8a35585bd2
commit d26b4fc5b7
1 changed files with 41 additions and 0 deletions

View File

@ -265,6 +265,47 @@ begin
assert_equal Time.gm(2001, 2, 1, 9, 0, 0), readme.lastrev.time
end
def test_entry
entry = @adapter.entry()
assert_equal "", entry.path
assert_equal "dir", entry.kind
entry = @adapter.entry('')
assert_equal "", entry.path
assert_equal "dir", entry.kind
assert_nil @adapter.entry('invalid')
assert_nil @adapter.entry('/invalid')
assert_nil @adapter.entry('/invalid/')
assert_nil @adapter.entry('invalid/invalid')
assert_nil @adapter.entry('invalid/invalid/')
assert_nil @adapter.entry('/invalid/invalid')
assert_nil @adapter.entry('/invalid/invalid/')
["README", "/README"].each do |path|
["0", "0885933ad4f6", "0885933ad4f68d77c2649cd11f8311276e7ef7ce"].each do |rev|
entry = @adapter.entry(path, rev)
assert_equal "README", entry.path
assert_equal "file", entry.kind
assert_equal '0', entry.lastrev.revision
assert_equal '0885933ad4f6', entry.lastrev.identifier
end
end
["sources", "/sources", "/sources/"].each do |path|
["0", "0885933ad4f6", "0885933ad4f68d77c2649cd11f8311276e7ef7ce"].each do |rev|
entry = @adapter.entry(path, rev)
assert_equal "sources", entry.path
assert_equal "dir", entry.kind
end
end
["sources/watchers_controller.rb", "/sources/watchers_controller.rb"].each do |path|
["0", "0885933ad4f6", "0885933ad4f68d77c2649cd11f8311276e7ef7ce"].each do |rev|
entry = @adapter.entry(path, rev)
assert_equal "sources/watchers_controller.rb", entry.path
assert_equal "file", entry.kind
assert_equal '0', entry.lastrev.revision
assert_equal '0885933ad4f6', entry.lastrev.identifier
end
end
end
def test_locate_on_outdated_repository
assert_equal 1, @adapter.entries("images", 0).size
assert_equal 2, @adapter.entries("images").size