Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/test/test_repos.rb view on Meta::CPAN
end
end
def test_commit_editor2
assert_commit_editor do |receiver, commit_callback_result, args|
commit_callback = Proc.new do |info|
commit_callback_result[:revision] = info.revision
commit_callback_result[:date] = info.date
commit_callback_result[:author] = info.author
end
receiver.commit_editor2(args[:repos_url], args[:base_path], args[:txn],
args[:user], args[:log_message], commit_callback)
end
end
def test_commit_editor3
assert_commit_editor do |receiver, commit_callback_result, args|
props = {
Svn::Core::PROP_REVISION_AUTHOR => args[:user],
Svn::Core::PROP_REVISION_LOG => args[:log_message],
}
commit_callback = Proc.new do |info|
commit_callback_result[:revision] = info.revision
commit_callback_result[:date] = info.date
commit_callback_result[:author] = info.author
end
receiver.commit_editor3(args[:repos_url], args[:base_path], args[:txn],
props, commit_callback)
end
end
def test_prop
file = "file"
path = File.join(@wc_path, file)
source = "sample source"
log = "sample log"
make_context(log) do |ctx|
File.open(path, "w") {|f| f.print(source)}
ctx.add(path)
ctx.ci(@wc_path)
assert_equal([
Svn::Core::PROP_REVISION_AUTHOR,
Svn::Core::PROP_REVISION_LOG,
Svn::Core::PROP_REVISION_DATE,
].sort,
@repos.proplist.keys.sort)
assert_equal(log, @repos.prop(Svn::Core::PROP_REVISION_LOG))
@repos.set_prop(@author, Svn::Core::PROP_REVISION_LOG, nil)
assert_nil(@repos.prop(Svn::Core::PROP_REVISION_LOG))
assert_equal([
Svn::Core::PROP_REVISION_AUTHOR,
Svn::Core::PROP_REVISION_DATE,
].sort,
@repos.proplist.keys.sort)
assert_raises(Svn::Error::ReposHookFailure) do
@repos.set_prop(@author, Svn::Core::PROP_REVISION_DATE, nil)
end
assert_not_nil(@repos.prop(Svn::Core::PROP_REVISION_DATE))
assert_nothing_raised do
@repos.set_prop(@author, Svn::Core::PROP_REVISION_DATE, nil, nil, nil,
false)
end
assert_nil(@repos.prop(Svn::Core::PROP_REVISION_DATE))
assert_equal([
Svn::Core::PROP_REVISION_AUTHOR,
].sort,
@repos.proplist.keys.sort)
end
end
def test_dump
file = "file"
path = File.join(@wc_path, file)
source = "sample source"
log = "sample log"
make_context(log) do |ctx|
File.open(path, "w") {|f| f.print(source)}
ctx.add(path)
rev1 = ctx.ci(@wc_path).revision
File.open(path, "a") {|f| f.print(source)}
rev2 = ctx.ci(@wc_path).revision
assert_nothing_raised do
@repos.dump_fs(nil, nil, rev1, rev2)
end
dump = StringIO.new("")
feedback = StringIO.new("")
@repos.dump_fs(dump, feedback, rev1, rev2)
dump_unless_feedback = StringIO.new("")
@repos.dump_fs(dump_unless_feedback, nil, rev1, rev2)
dump.rewind
dump_unless_feedback.rewind
assert_equal(dump.read, dump_unless_feedback.read)
end
end
def test_load
file = "file"
path = File.join(@wc_path, file)
source = "sample source"
log = "sample log"
make_context(log) do |ctx|
File.open(path, "w") {|f| f.print(source)}
ctx.add(path)
rev1 = ctx.ci(@wc_path).revision
File.open(path, "a") {|f| f.print(source)}
rev2 = ctx.ci(@wc_path).revision
dump = StringIO.new("")
@repos.dump_fs(dump, nil, rev1, rev2)
dest_path = File.join(@tmp_path, "dest")
Svn::Repos.create(dest_path) do |repos|
assert_raises(NoMethodError) do
repos.load_fs(nil)
end
end
[
[StringIO.new(""), Svn::Repos::LOAD_UUID_DEFAULT, "/"],
[StringIO.new("")],
[],
].each_with_index do |args, i|
dest_path = File.join(@tmp_path, "dest#{i}")
Svn::Repos.create(dest_path) do |repos|
assert_not_equal(@repos.fs.root.committed_info("/"),
repos.fs.root.committed_info("/"))
dump.rewind
repos.load_fs(dump, *args)
assert_equal(@repos.fs.root.committed_info("/"),
repos.fs.root.committed_info("/"))
end
end
end
end
def test_node_editor
file = "file"
dir1 = "dir1"
dir2 = "dir2"
dir3 = "dir3"
dir1_path = File.join(@wc_path, dir1)
dir2_path = File.join(dir1_path, dir2)
dir3_path = File.join(dir2_path, dir3)
path = File.join(dir3_path, file)
source = "sample source"
log = "sample log"
make_context(log) do |ctx|
FileUtils.mkdir_p(dir3_path)
FileUtils.touch(path)
ctx.add(dir1_path)
rev1 = ctx.ci(@wc_path).revision
ctx.rm(dir3_path)
rev2 = ctx.ci(@wc_path).revision
rev1_root = @repos.fs.root(rev1)
rev2_root = @repos.fs.root(rev2)
editor = @repos.node_editor(rev1_root, rev2_root)
rev2_root.replay(editor)
tree = editor.baton.node
assert_equal("", tree.name)
assert_equal(dir1, tree.child.name)
assert_equal(dir2, tree.child.child.name)
end
end
def test_lock
file = "file"
log = "sample log"
path = File.join(@wc_path, file)
path_in_repos = "/#{file}"
make_context(log) do |ctx|
FileUtils.touch(path)
ctx.add(path)
rev = ctx.ci(@wc_path).revision
access = Svn::Fs::Access.new(@author)
@repos.fs.access = access
lock = @repos.lock(file)
locks = @repos.get_locks(file)
assert_equal([path_in_repos], locks.keys)
( run in 0.733 second using v1.01-cache-2.11-cpan-524268b4103 )