Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/test/test_wc.rb view on Meta::CPAN
require "svn/wc"
require "svn/repos"
require "svn/ra"
class SvnWcTest < Test::Unit::TestCase
include SvnTestUtil
def setup
setup_basic
end
def teardown
teardown_basic
end
def test_version
assert_equal(Svn::Core.subr_version, Svn::Wc.version)
end
def test_status
file1 = "a"
file1_path = File.join(@wc_path, file1)
Svn::Wc::AdmAccess.open(nil, @wc_path, false, 0) do |adm|
status = adm.status(file1_path)
assert_equal(Svn::Wc::STATUS_NONE, status.text_status)
assert_nil(status.entry)
end
non_exist_child_path = File.join(@wc_path, "NOT-EXIST")
assert_nothing_raised do
Svn::Wc::AdmAccess.probe_open(nil, non_exist_child_path, false, 0){}
end
FileUtils.touch(file1_path)
Svn::Wc::AdmAccess.open(nil, @wc_path, false, 0) do |adm|
status = adm.status(file1_path)
assert_equal(Svn::Wc::STATUS_UNVERSIONED, status.text_status)
assert_nil(status.entry)
end
log = "sample log"
make_context(log) do |ctx|
ctx.add(file1_path)
Svn::Wc::AdmAccess.open(nil, @wc_path, false, 0) do |adm|
status = adm.status(file1_path)
assert_equal(Svn::Wc::STATUS_ADDED, status.text_status)
end
commit_info = ctx.commit(@wc_path)
Svn::Wc::AdmAccess.open(nil, @wc_path, false, 0) do |adm|
status = adm.status(file1_path)
assert_equal(Svn::Wc::STATUS_NORMAL, status.text_status)
assert_equal(commit_info.revision, status.entry.revision)
end
end
end
def test_wc
assert_not_equal(0, Svn::Wc.check_wc(@wc_path))
assert(Svn::Wc.normal_prop?("name"))
assert(Svn::Wc.wc_prop?("#{Svn::Core::PROP_WC_PREFIX}name"))
assert(Svn::Wc.entry_prop?("#{Svn::Core::PROP_ENTRY_PREFIX}name"))
end
def test_adm_access
log = "sample log"
source = "sample source"
dir = "dir"
file = "file"
prop_name = "name"
prop_value = "value"
dir_path = File.join(@wc_path, dir)
path = File.join(dir_path, file)
make_context(log) do |ctx|
ctx.mkdir(dir_path)
File.open(path, "w") {|f| f.print(source)}
ctx.add(path)
rev = ctx.ci(@wc_path).revision
result = Svn::Wc::AdmAccess.open_anchor(path, true, 5)
anchor_access, target_access, target = result
assert_equal(file, target)
assert_equal(dir_path, anchor_access.path)
assert_equal(dir_path, target_access.path)
assert(anchor_access.locked?)
assert(target_access.locked?)
assert(!target_access.has_binary_prop?(path))
assert(!target_access.text_modified?(path))
assert(!target_access.props_modified?(path))
File.open(path, "w") {|f| f.print(source * 2)}
target_access.set_prop(prop_name, prop_value, path)
assert_equal(prop_value, target_access.prop(prop_name, path))
assert_equal({prop_name => prop_value},
target_access.prop_list(path))
assert(target_access.text_modified?(path))
assert(target_access.props_modified?(path))
target_access.set_prop("name", nil, path)
assert(!target_access.props_modified?(path))
target_access.revert(path)
assert(!target_access.text_modified?(path))
assert(!target_access.props_modified?(path))
anchor_access.close
target_access.close
access = Svn::Wc::AdmAccess.probe_open(nil, path, false, 5)
assert(!Svn::Wc.default_ignores({}).empty?)
assert_equal(Svn::Wc.default_ignores({}), access.ignores({}))
assert(access.wc_root?(@wc_path))
access.close
access = Svn::Wc::AdmAccess.probe_open(nil, @wc_path, false, 5)
src/subversion/subversion/bindings/swig/ruby/test/test_wc.rb view on Meta::CPAN
access.relocate(@wc_path, @repos_uri, dir2_uri) do |uuid, url, root_url|
values << [uuid, url, root_url]
end
assert(!values.empty?)
assert(dir2_uri, access.entry(@wc_path).url)
end
end
end
end
def test_ignore?
assert(!Svn::Wc.ignore?("xxx.c", []))
assert(Svn::Wc.ignore?("xxx.c", ["*.c"]))
assert(!Svn::Wc.ignore?("xxx.c", ["XXX.c"]))
assert(Svn::Wc.ignore?("xxx.c", ["xxx.c"]))
assert(!Svn::Wc.ignore?("xxx.c", ["*.H", "*.C"]))
assert(Svn::Wc.ignore?("xxx.C", ["*.H", "*.C"]))
end
def test_changelist
log = "sample log"
file = "hello.txt"
src = "Hello"
path = File.join(@wc_path, file)
make_context(log) do |ctx|
File.open(path, "w") {|f| f.print(src)}
ctx.add(path)
rev1 = ctx.commit(@wc_path).revision
end
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
assert_nil(access.entry(@wc_path).changelist)
end
notifies = []
notify_collector = Proc.new {|notify| notifies << notify }
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
access.set_changelist(path, "123", nil, notify_collector)
end
assert_equal([[File.expand_path(path), nil]],
notifies.collect {|notify| [notify.path, notify.err]})
notifies = []
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
access.set_changelist(path, "456", nil, notify_collector)
end
assert_equal([[File.expand_path(path), Svn::Wc::NOTIFY_CHANGELIST_CLEAR],
[File.expand_path(path), Svn::Wc::NOTIFY_CHANGELIST_SET]],
notifies.collect {|notify| [notify.path, notify.action]})
notifies = []
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
access.set_changelist(@wc_path, "789", nil, notify_collector)
end
end
def test_context_new_default_config
assert_not_nil context = Svn::Wc::Context.new
ensure
context.destroy
end
def test_context_new_specified_config
config_file = File.join(@config_path, Svn::Core::CONFIG_CATEGORY_CONFIG)
config = Svn::Core::Config.read(config_file)
assert_not_nil context = Svn::Wc::Context.new(:config=>config)
ensure
context.destroy
end
def test_context_create
assert_nothing_raised do
result = Svn::Wc::Context.create do |context|
assert_not_nil context
assert_kind_of Svn::Wc::Context, context
end
if RUBY_VERSION > '1.9'
assert_equal(result,true)
else
assert_nil result
end
end
end
end
( run in 1.046 second using v1.01-cache-2.11-cpan-524268b4103 )