File: test_git_path.rb

package info (click to toggle)
ruby-git 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,124 kB
  • sloc: ruby: 5,385; sh: 507; perl: 64; makefile: 6
file content (47 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../test_helper'

class TestGitPath < Test::Unit::TestCase

  def setup
    set_file_paths
    @git = Git.open(@wdir)
  end

  def test_initalize_with_good_path_and_check_path
    path = Git::Path.new(@git.index.to_s, true)
    assert_equal @git.index.to_s, path.to_s
  end

  def test_initialize_with_bad_path_and_check_path
    assert_raises ArgumentError do
      Git::Path.new('/this path does not exist', true)
    end
  end

  def test_initialize_with_bad_path_and_no_check
    path = Git::Path.new('/this path does not exist', false)
    assert path.to_s.end_with?('/this path does not exist')

    assert(path.to_s.match(%r{^(?:[A-Z]:)?/this path does not exist$}))
  end

  def test_readables
    assert(@git.dir.readable?)
    assert(@git.index.readable?)
    assert(@git.repo.readable?)
  end

  def test_readables_in_temp_dir
    in_temp_dir do |dir|
      FileUtils.cp_r(@wdir, 'test')
      g = Git.open(File.join(dir, 'test'))

      assert(g.dir.writable?)
      assert(g.index.writable?)
      assert(g.repo.writable?)
    end
  end

end