Permalink
Browse files

some small updates to the test suite

- add beginning of config test (implementation is not complete)
- add reference listing tests
- add first tree builder test
  • Loading branch information...
1 parent a965540 commit 5dd236399670cae8bd32348dc2360a18cc4f6adb @schacon schacon committed Nov 29, 2011
Showing with 34 additions and 5 deletions.
  1. +12 −0 test/config_test.rb
  2. +5 −0 test/reference_test.rb
  3. +17 −5 test/tree_test.rb
View
@@ -0,0 +1,12 @@
+require File.expand_path "../test_helper", __FILE__
+
+context "Rugged::Config tests" do
+ setup do
+ @path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
+ @repo = Rugged::Repository.new(@path)
+ end
+
+ xtest "can read the commit data" do
+ #pp config = Rugged::Config.new(File.join(@repo.path, 'config'))
+ end
+end
View
@@ -10,6 +10,11 @@
FileUtils.remove_entry_secure(@path + '/refs/heads/unit_test', true)
end
+ test "can list references" do
+ refs = @repo.refs.map { |r| r.gsub("refs/", '') }.sort.join(':')
+ assert_equal "heads/master:heads/packed:tags/v0.9:tags/v1.0", refs
+ end
+
test "can open reference" do
ref = Rugged::Reference.lookup(@repo, "refs/heads/master")
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", ref.target
View
@@ -10,20 +10,22 @@
test "can read the tree data" do
assert_equal @oid, @tree.oid
- assert_equal "tree", @tree.type
- assert_equal 3, @tree.count
- assert_equal "1385f264afb75a56a5bec74243be9b367ba4ca08", @tree[0][:oid]
- assert_equal "fa49b077972391ad58037050f2a75f74e3671e92", @tree[1][:oid]
+ assert_equal "tree", @tree.type
+ assert_equal 3, @tree.count
+ assert_equal "1385f264afb75a56a5bec74243be9b367ba4ca08", @tree[0][:oid]
+ assert_equal "fa49b077972391ad58037050f2a75f74e3671e92", @tree[1][:oid]
end
test "can read the tree entry data" do
bent = @tree[0]
tent = @tree[2]
assert_equal "README", bent[:name]
+ assert_equal :blob, bent[:type]
# assert_equal 33188, bent.attributes
assert_equal "subdir", tent[:name]
+ assert_equal :tree, tent[:type]
assert_equal "619f9935957e010c419cb9d15621916ddfcc0b96", tent[:oid]
assert_equal "tree", @repo.lookup(tent[:oid]).type
end
@@ -52,7 +54,17 @@
@tree.each_blob {|tree| assert_equal :blob, tree[:type]}
end
- xtest "can write the tree data" do
+ test "can write the tree data" do
+ entry = {:type => :blob,
+ :path => "README.txt",
+ :oid => "1385f264afb75a56a5bec74243be9b367ba4ca08",
+ :attributes => 33188}
+
+ builder = Rugged::Tree::Builder.new
+ builder << entry
+ sha = builder.write(@repo)
+ obj = @repo.lookup(sha)
+ assert_equal 38, obj.read_raw.len
end
end

0 comments on commit 5dd2363

Please sign in to comment.