Alien-SVN

 view release on metacpan or  search on metacpan

src/subversion/subversion/bindings/swig/ruby/test/test_fs.rb  view on Meta::CPAN

      assert_equal(Digest::MD5.hexdigest(src),
                   @fs.root.file_md5_checksum(path_in_repos))

      assert_equal([path_in_repos], @fs.root.paths_changed.keys)
      info = @fs.root.paths_changed[path_in_repos]
      assert(info.text_mod?)
      assert(info.modify?)

      assert_equal([path_in_repos, rev2],
                   @fs.root.node_history(file).location)
      assert_equal([path_in_repos, rev2],
                   @fs.root.node_history(file).prev.location)
      assert_equal([path_in_repos, rev1],
                   @fs.root.node_history(file).prev.prev.location)

      assert(!@fs.root.dir?(path_in_repos))
      assert(@fs.root.file?(path_in_repos))

      assert(file_id1.related?(file_id2))
      assert_equal(1, file_id1.compare(file_id2))
      assert_equal(1, file_id2.compare(file_id1))

      assert_equal(rev2, @fs.root.node_created_rev(path_in_repos))
      assert_equal(path_in_repos, @fs.root.node_created_path(path_in_repos))

      assert_raises(Svn::Error::FsNotTxnRoot) do
        @fs.root.set_node_prop(path_in_repos, "name", "value")
      end
    end
  end

  def test_transaction
    log = "sample log"
    file = "sample.txt"
    src = "sample source"
    path_in_repos = "/#{file}"
    path = File.join(@wc_path, file)
    prop_name = "prop"
    prop_value = "value"

    make_context(log) do |ctx|
      File.open(path, "w") {|f| f.print(src)}
      ctx.add(path)
      ctx.commit(@wc_path)
    end

    assert_raises(Svn::Error::FsNoSuchTransaction) do
      @fs.open_txn("NOT-EXIST")
    end

    start_time = Time.now
    txn1 = @fs.transaction
    assert_equal([Svn::Core::PROP_REVISION_DATE], txn1.proplist.keys)
    assert_instance_of(Time, txn1.proplist[Svn::Core::PROP_REVISION_DATE])
    date = txn1.prop(Svn::Core::PROP_REVISION_DATE)

    # Subversion's clock is more precise than Ruby's on
    # Windows.  So this test can fail intermittently because
    # the begin and end of the range are the same (to 3
    # decimal places), but the time from Subversion has 6
    # decimal places so it looks like it's not in the range.
    # So we just add a smidgen to the end of the Range.
    assert_operator(start_time..(Time.now + 0.001), :include?, date)
    txn1.set_prop(Svn::Core::PROP_REVISION_DATE, nil)
    assert_equal([], txn1.proplist.keys)
    assert_equal(youngest_rev, txn1.base_revision)
    assert(txn1.root.txn_root?)
    assert(!txn1.root.revision_root?)
    assert_equal(txn1.name, txn1.root.name)
    assert_equal(txn1.base_revision, txn1.root.base_revision)

    @fs.transaction do |txn|
      assert_nothing_raised do
        @fs.open_txn(txn.name)
      end
      txn2 = txn
    end

    txn3 = @fs.transaction

    assert_equal([txn1.name, txn3.name].sort, @fs.transactions.sort)
    @fs.purge_txn(txn3.name)
    assert_equal([txn1.name].sort, @fs.transactions.sort)

    @fs.transaction do |txn|
      assert(@fs.transactions.include?(txn.name))
      txn.abort
      assert(!@fs.transactions.include?(txn.name))
    end

    txn4 = @fs.transaction
    assert_equal({}, txn1.root.node_proplist(path_in_repos))
    assert_nil(txn1.root.node_prop(path_in_repos, prop_name))
    txn1.root.set_node_prop(path_in_repos, prop_name, prop_value)
    assert_equal(prop_value, txn1.root.node_prop(path_in_repos, prop_name))
    assert_equal({prop_name => prop_value},
                 txn1.root.node_proplist(path_in_repos))
    assert(txn1.root.props_changed?(path_in_repos, txn4.root, path_in_repos))
    assert(!txn1.root.props_changed?(path_in_repos, txn1.root, path_in_repos))
    txn1.root.set_node_prop(path_in_repos, prop_name, nil)
    assert_nil(txn1.root.node_prop(path_in_repos, prop_name))
    assert_equal({}, txn1.root.node_proplist(path_in_repos))
  end

  def test_operation
    log = "sample log"
    file = "sample.txt"
    file2 = "sample2.txt"
    file3 = "sample3.txt"
    dir = "sample"
    src = "sample source"
    path_in_repos = "/#{file}"
    path2_in_repos = "/#{file2}"
    path3_in_repos = "/#{file3}"
    dir_path_in_repos = "/#{dir}"
    path = File.join(@wc_path, file)
    path2 = File.join(@wc_path, file2)
    path3 = File.join(@wc_path, file3)
    dir_path = File.join(@wc_path, dir)
    token = @fs.generate_lock_token
    make_context(log) do |ctx|



( run in 1.410 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )