⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_client.rb

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 RB
📖 第 1 页 / 共 4 页
字号:
    ctx.merge_peg(branch, rev3, rev4, trunk, nil, true, false, true, true)    assert(File.exist?(trunk_path))        ctx.merge_peg(branch, rev3, rev4, trunk, nil, true, false, true)    rev6 = ctx.commit(@wc_path).revision    assert(!File.exist?(trunk_path))  end  def test_cleanup    log = "sample log"    file = "sample.txt"    src = "sample\n"    path = File.join(@wc_path, file)    ctx = make_context(log)    File.open(path, "w") {|f| f.print(src)}    ctx.add(path)    rev = ctx.commit(@wc_path).revision    ctx.up(@wc_path, rev - 1)    File.open(path, "w") {|f| f.print(src)}        gc_disable do      assert_raise(Svn::Error::WC_OBSTRUCTED_UPDATE) do        ctx.up(@wc_path, rev)      end      assert_raise(Svn::Error::WC_LOCKED) do        ctx.commit(@wc_path)      end      ctx.set_cancel_func do        raise Svn::Error::CANCELLED      end      assert_raise(Svn::Error::CANCELLED) do        ctx.cleanup(@wc_path)      end      assert_raise(Svn::Error::WC_LOCKED) do        ctx.commit(@wc_path)      end      ctx.set_cancel_func(nil)      assert_nothing_raised do        ctx.cleanup(@wc_path)      end      assert_nothing_raised do        ctx.commit(@wc_path)      end    end  end  def test_relocate    log = "sample log"    file = "sample.txt"    src = "sample\n"    path = File.join(@wc_path, file)    ctx = make_context(log)    File.open(path, "w") {|f| f.print(src)}    ctx.add(path)    ctx.commit(@wc_path)    assert_nothing_raised do      ctx.cat(path)    end    ctx.add_simple_prompt_provider(0) do |cred, realm, username, may_save|      cred.username = @author      cred.password = @password      cred.may_save = true    end    ctx.relocate(@wc_path, @repos_uri, @repos_svnserve_uri)        ctx = make_context(log)    assert_raises(Svn::Error::AUTHN_NO_PROVIDER) do      ctx.cat(path)    end  end  def test_resolved    log = "sample log"    file = "sample.txt"    dir = "dir"    src1 = "before\n"    src2 = "after\n"    dir_path = File.join(@wc_path, dir)    path = File.join(dir_path, file)    ctx = make_context(log)    ctx.mkdir(dir_path)    File.open(path, "w") {}    ctx.add(path)    rev1 = ctx.ci(@wc_path).revision    File.open(path, "w") {|f| f.print(src1)}    rev2 = ctx.ci(@wc_path).revision    ctx.up(@wc_path, rev1)    File.open(path, "w") {|f| f.print(src2)}    ctx.up(@wc_path)    assert_raises(Svn::Error::WC_FOUND_CONFLICT) do      ctx.ci(@wc_path)    end    ctx.resolved(dir_path, false)    assert_raises(Svn::Error::WC_FOUND_CONFLICT) do      ctx.ci(@wc_path)    end    ctx.resolved(dir_path)    info = nil    assert_nothing_raised do      info = ctx.ci(@wc_path)    end    assert_not_nil(info)    assert_equal(rev2 + 1, info.revision)  end  def test_copy    log = "sample log"    src = "source\n"    file1 = "sample1.txt"    file2 = "sample2.txt"    path1 = File.join(@wc_path, file1)    path2 = File.join(@wc_path, file2)    ctx = make_context(log)    File.open(path1, "w") {|f| f.print(src)}    ctx.add(path1)    ctx.ci(@wc_path)    ctx.cp(path1, path2)    infos = []    ctx.set_notify_func do |notify|      infos << [notify.path, notify]    end    ctx.ci(@wc_path)    assert_equal([path2].sort,                 infos.collect{|path, notify| path}.sort)    path2_notify = infos.assoc(path2)[1]    assert(path2_notify.commit_added?)    assert_equal(File.open(path1) {|f| f.read},                 File.open(path2) {|f| f.read})  end    def test_move    log = "sample log"    src = "source\n"    file1 = "sample1.txt"    file2 = "sample2.txt"    path1 = File.join(@wc_path, file1)    path2 = File.join(@wc_path, file2)    ctx = make_context(log)    File.open(path1, "w") {|f| f.print(src)}    ctx.add(path1)    ctx.ci(@wc_path)    ctx.mv(path1, path2)    infos = []    ctx.set_notify_func do |notify|      infos << [notify.path, notify]    end    ctx.ci(@wc_path)    assert_equal([path1, path2].sort,                 infos.collect{|path, notify| path}.sort)    path1_notify = infos.assoc(path1)[1]    assert(path1_notify.commit_deleted?)    path2_notify = infos.assoc(path2)[1]    assert(path2_notify.commit_added?)    assert_equal(src, File.open(path2) {|f| f.read})  end    def test_move_force    log = "sample log"    src1 = "source1\n"    src2 = "source2\n"    file1 = "sample1.txt"    file2 = "sample2.txt"    path1 = File.join(@wc_path, file1)    path2 = File.join(@wc_path, file2)    ctx = make_context(log)    File.open(path1, "w") {|f| f.print(src1)}    ctx.add(path1)    ctx.ci(@wc_path)    File.open(path1, "w") {|f| f.print(src2)}    assert_raises(Svn::Error::CLIENT_MODIFIED) do      ctx.mv(path1, path2)    end    ctx.cleanup(@wc_path)    assert_nothing_raised do      ctx.mv_f(path1, path2)    end    notifies = []    ctx.set_notify_func do |notify|      notifies << notify    end    ctx.ci(@wc_path)    paths = notifies.collect do |notify|      notify.path    end    assert_equal([path1, path2, path2].sort, paths.sort)    deleted_paths = notifies.find_all do |notify|      notify.commit_deleted?    end.collect do |notify|      notify.path    end    assert_equal([path1].sort, deleted_paths.sort)    added_paths = notifies.find_all do |notify|      notify.commit_added?    end.collect do |notify|      notify.path    end    assert_equal([path2].sort, added_paths.sort)    postfix_txdelta_paths = notifies.find_all do |notify|      notify.commit_postfix_txdelta?    end.collect do |notify|      notify.path    end    assert_equal([path2].sort, postfix_txdelta_paths.sort)    assert_equal(src2, File.open(path2) {|f| f.read})  end  def test_prop    log = "sample log"    dir = "dir"    file = "sample.txt"    dir_path = File.join(@wc_path, dir)    dir_uri = "#{@repos_uri}/#{dir}"    path = File.join(dir_path, file)    uri = "#{dir_uri}/#{file}"    prop_name = "sample-prop"    prop_value = "sample value"    invalid_mime_type_prop_value = "image"    ctx = make_context(log)    ctx.mkdir(dir_path)    File.open(path, "w") {}    ctx.add(path)    ctx.commit(@wc_path)    assert_equal({}, ctx.prop_get(prop_name, path))    ctx.prop_set(prop_name, prop_value, path)    ctx.commit(@wc_path)    assert_equal({uri => prop_value}, ctx.pget(prop_name, path))        ctx.prop_del(prop_name, path)    ctx.commit(@wc_path)    assert_equal({}, ctx.pg(prop_name, path))        ctx.ps(prop_name, prop_value, path)    ctx.commit(@wc_path)    assert_equal({uri => prop_value}, ctx.pg(prop_name, path))    ctx.ps(prop_name, nil, path)    ctx.commit(@wc_path)    assert_equal({}, ctx.pg(prop_name, path))    ctx.up(@wc_path)    ctx.ps(prop_name, prop_value, dir_path)    ctx.ci(@wc_path)    assert_equal({                   dir_uri => prop_value,                   uri => prop_value,                 },                 ctx.pg(prop_name, dir_path))    ctx.up(@wc_path)    ctx.pdel(prop_name, dir_path, false)    ctx.ci(@wc_path)    assert_equal({uri => prop_value}, ctx.pg(prop_name, dir_path))        ctx.up(@wc_path)    ctx.pd(prop_name, dir_path)    ctx.ci(@wc_path)    assert_equal({}, ctx.pg(prop_name, dir_path))        ctx.up(@wc_path)    ctx.ps(prop_name, prop_value, dir_path, false)    ctx.ci(@wc_path)    assert_equal({dir_uri => prop_value}, ctx.pg(prop_name, dir_path))    assert_raises(Svn::Error::BAD_MIME_TYPE) do      ctx.ps(Svn::Core::PROP_MIME_TYPE,             invalid_mime_type_prop_value,             path)    end    ctx.cleanup(@wc_path)    assert_nothing_raised do      ctx.ps(Svn::Core::PROP_MIME_TYPE,             invalid_mime_type_prop_value,             path, false, true)    end    ctx.commit(@wc_path)    assert_equal({uri => invalid_mime_type_prop_value},                 ctx.pg(Svn::Core::PROP_MIME_TYPE, path))  end    def test_prop_list    log = "sample log"    dir = "dir"    file = "sample.txt"    dir_path = File.join(@wc_path, dir)    path = File.join(dir_path, file)    dir_uri = "#{@repos_uri}/#{dir}"    uri = "#{dir_uri}/#{file}"    name1 = "name1"    name2 = "name2"    value1 = "value1"    value2 = "value2"    ctx = make_context(log)    ctx.mkdir(dir_path)    File.open(path, "w") {}    ctx.add(path)    ctx.ci(@wc_path)    assert_equal([], ctx.prop_list(path))        ctx.ps(name1, value1, path)    ctx.ci(@wc_path)    assert_equal([uri], ctx.prop_list(path).collect{|item| item.node_name})    assert_equal([{name1 => value1}],                 ctx.plist(path).collect{|item| item.prop_hash})    assert_equal([value1], ctx.pl(path).collect{|item| item[name1]})    ctx.up(@wc_path)    ctx.ps(name2, value2, dir_path)    ctx.ci(@wc_path)    assert_equal([uri, dir_uri].sort,                 ctx.prop_list(dir_path).collect{|item| item.name})    prop_list = ctx.plist(dir_path).collect{|item| [item.name, item.props]}    props = prop_list.assoc(uri)[1]    dir_props = prop_list.assoc(dir_uri)[1]    assert_equal({name1 => value1, name2 => value2}, props)    assert_equal({name2 => value2}, dir_props)  end    def test_cat    log = "sample log"    src1 = "source1\n"    src2 = "source2\n"    file = "sample.txt"    path = File.join(@wc_path, file)    File.open(path, "w") {|f| f.print(src1)}    ctx = make_context(log)    ctx.add(path)    commit_info = ctx.commit(@wc_path)    rev1 = commit_info.revision    assert_equal(src1, ctx.cat(path, rev1))    assert_equal(src1, ctx.cat(path))        File.open(path, "w") {|f| f.print(src2)}    commit_info = ctx.commit(@wc_path)    rev2 = commit_info.revision    assert_equal(src1, ctx.cat(path, rev1))    assert_equal(src2, ctx.cat(path, rev2))    assert_equal(src2, ctx.cat(path))  end  def test_lock    log = "sample log"    src = "source\n"    file = "sample.txt"    path = File.join(@wc_path, file)    File.open(path, "w") {|f| f.print(src)}    ctx = make_context(log)    ctx.add(path)    ctx.commit(@wc_path)    infos = []    ctx.set_notify_func do |notify|      infos << [notify.path, notify]    end    ctx.lock(path)    assert_equal([file], infos.collect{|path, notify| path})    file_notify = infos.assoc(file)[1]    assert(file_notify.locked?)  end    def test_unlock    log = "sample log"    src = "source\n"    file = "sample.txt"    path = File.join(@wc_path, file)    File.open(path, "w") {|f| f.print(src)}    ctx = make_context(log)    ctx.add(path)    ctx.commit(@wc_path)    ctx.lock(path)    infos = []    ctx.set_notify_func do |notify|      infos << [notify.path, notify]    end    ctx.unlock(path)    assert_equal([file], infos.collect{|path, notify| path})    file_notify = infos.assoc(file)[1]    assert(file_notify.unlocked?)  end  def test_info    log = "sample log"    ctx = make_context(log)    repos_base = File.basename(@repos_path)    infos = []    ctx.info(@wc_path) do |path, info|      infos << [path, info]    end    assert_equal([repos_base],                 infos.collect{|path, info| path})    top_info = infos.assoc(repos_base)[1]    assert_equal(@repos_uri, top_info.url)  end  def test_url_from_path    log = "sample log"    ctx = make_context(log)    assert_equal(@repos_uri, ctx.url_from_path(@wc_path))    assert_equal(@repos_uri, Svn::Client.url_from_path(@wc_path))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -