Sha256: b0cbd2185fdf4679bf5bf85f3b9999321eb7d0b2d6ac03b86e6a950c14aa6d7c

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

require 'dandelion/git'
require 'test/unit'

class TestGit < Test::Unit::TestCase
  def setup
    @repo = Dandelion::Git::Repo.new(File.join(File.dirname(__FILE__), 'test_git.git'))
  end

  def test_tree_files
    tree = Dandelion::Git::Tree.new(@repo, 'HEAD', '')
    files = ['foo', 'bar', 'baz/foo', 'baz/bar']
    assert_equal files.sort, tree.files.sort
  end

  def test_tree_subfolder
    tree = Dandelion::Git::Tree.new(@repo, 'HEAD', 'baz')
    files = ['foo', 'bar']
    assert_equal files.sort, tree.files.sort
  end

  def test_tree_show
    tree = Dandelion::Git::Tree.new(@repo, 'HEAD', '')
    assert_equal "bar\n", tree.show('foo')
    assert_equal "bar\n", tree.show('baz/foo')
  end

  def test_tree_revision
    revision = 'ff1f1d4bd0c99e1c9cca047c46b2194accf89504'
    tree = Dandelion::Git::Tree.new(@repo, revision, '')
    assert_equal revision, tree.revision
  end

  def test_diff_changed
    from = 'ff1f1d4bd0c99e1c9cca047c46b2194accf89504'
    to = '88d4480861346093048e08ce8dcc577d8aa69379'
    files = ['foo', 'baz/foo']
    diff = Dandelion::Git::Diff.new(@repo, from, to, '')
    assert_equal files.sort, diff.changed.sort
    assert_equal [], diff.deleted
  end

  def test_diff_deleted
    from = 'f55f3c44c89e5d215fbaaef9d33563117fe0b61b'
    to = '0ca605e9f0f1d42ce8193ac36db11ec3cc9efc08'
    files = ['test_delete']
    diff = Dandelion::Git::Diff.new(@repo, from, to, '')
    assert_equal files.sort, diff.deleted.sort
    assert_equal [], diff.changed
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dandelion-0.3.15 test/test_git.rb
dandelion-0.3.14 test/test_git.rb
dandelion-0.3.13 test/test_git.rb
dandelion-0.3.12 test/test_git.rb