./test/dolt/git/repository_test.rb in dolt-0.1.0 vs ./test/dolt/git/repository_test.rb in dolt-0.1.1

- old
+ new

@@ -26,11 +26,19 @@ @cmds = [] @deferreds = [] end def show(path, ref) - cmds << ["show", path, ref] + git("show", path, ref) + end + + def ls_tree(path, ref) + git("ls-tree", path, ref) + end + + def git(*args) + cmds << args deferred = When::Deferred.new deferreds << deferred.resolver deferred.promise end @@ -63,8 +71,39 @@ d.callback do |blob| assert_equal "class Repository;end", blob.raw end @git.last_resolver.resolve("class Repository;end") + end + end + + describe "#tree" do + it "uses git ls-tree to list tree" do + repo = Dolt::Git::Repository.new("gitorious", @git) + repo.tree("app/models", "master") + + assert_equal ["ls-tree", "app/models", "master"], @git.last_command + end + + it "defaults to listing tree at HEAD" do + repo = Dolt::Git::Repository.new("gitorious", @git) + repo.tree("app/models") + + assert_equal ["ls-tree", "app/models", "HEAD"], @git.last_command + end + + it "invokes callback with tree object" do + repo = Dolt::Git::Repository.new("gitorious", @git) + d = repo.tree("app/models") + + d.callback do |tree| + assert_equal 3, tree.entries.length + end + + @git.last_resolver.resolve(<<-GIT) +100644 blob e90021f89616ddf86855d05337c188408d3b417e .gitmodules +100644 blob c80ee3697054566d1a4247d80be78ec3ddfde295 Gemfile +100644 blob 0053b3c95b0d9faa4916f7cd5e559c2b0f138027 Gemfile.lock + GIT end end end