public this repo is viewable by everyone
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
commit  1cef7b69dff6ad3bd62e5127a38f2de73ee89456
tree    531c3f4e39de7494ad28813361de00dc968d7e40
parent  e90f935a38bb88f37da5a3ba849531173c107413
piston / test / unit / git / commit / test_git_commit_checkout.rb
100644 29 lines (26 sloc) 1.392 kb
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
require File.dirname(__FILE__) + "/../../../test_helper"
 
class TestGitCommitCheckout < Test::Unit::TestCase
  def setup
    @repos = mock("repos")
    @repos.stubs(:url).returns("git://a.repos.com/project.git")
    @reposdir = Pathname.new("tmp/.repos.tmp.git")
  end
 
  def test_clones_repository_at_indicated_path
    @sha1 = "a9302"
    @commit = Piston::Git::Commit.new(@repos, @sha1)
    @commit.expects(:git).with(:clone, @repos.url, @reposdir)
    @commit.expects(:git).with(:checkout, "-b", "my-#{@sha1}", @sha1)
    Dir.expects(:chdir).with(@reposdir).yields
    @commit.checkout_to(@reposdir)
  end
 
  def test_cloning_head_finds_head_commit
    @sha1 = "HEAD"
    @commit = Piston::Git::Commit.new(@repos, @sha1)
    @commit.expects(:git).with(:clone, @repos.url, @reposdir)
    @commit.expects(:git).with(:checkout, "-b", "my-#{@sha1}", @sha1)
    @commit.expects(:git).with(:log, "-n", "1").returns("commit 922b12a6bcbb6f6a2cec60bcf5de17118086080a\nAuthor: Fran\303\247ois Beausoleil <francois@teksol.info>\nDate: Fri Mar 14 13:28:41 2008 -0400\n\n Changed how dependencies are found and managed, by using config/requirements.rb everywhere.\n \n Updated test/test_helper.rb where appropriate.\n")
    Dir.expects(:chdir).with(@reposdir).yields
    @commit.checkout_to(@reposdir)
    assert_equal "922b12a6bcbb6f6a2cec60bcf5de17118086080a", @commit.revision
  end
end