forked from mojombo/grit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_head.rb
53 lines (40 loc) · 1.14 KB
/
test_head.rb
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
48
49
50
51
52
53
require File.dirname(__FILE__) + '/helper'
class TestHead < Test::Unit::TestCase
def setup
@r = Repo.new(File.join(File.dirname(__FILE__), *%w[dot_git]), :is_bare => true)
end
# inspect
def test_inspect
head = @r.heads[1]
assert_equal %Q{#<Grit::Head "test/master">}, head.inspect
end
def test_master
head = @r.commit('master')
assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', head.id
end
def test_head_commit
head = @r.head
assert_equal 'master', head.name
assert_equal 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a', head.commit.sha
end
def test_submaster
head = @r.commit('test/master')
assert_equal '2d3acf90f35989df8f262dc50beadc4ee3ae1560', head.id
end
# heads with slashes
def test_heads_with_slashes
head = @r.heads[3]
assert_equal %Q{#<Grit::Head "test/chacon">}, head.inspect
end
def test_is_head
assert @r.is_head?('master')
assert @r.is_head?('test/chacon')
assert [email protected]_head?('masterblah')
end
def test_head_count
assert_equal 5, @r.heads.size
end
def test_nonpack
assert @r.heads.map { |h| h.name }.include?('nonpack')
end
end