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
Moving around where tests live, to better group them.
20 days ago
francois (committer)
18 days ago
commit  1cef7b69dff6ad3bd62e5127a38f2de73ee89456
tree    531c3f4e39de7494ad28813361de00dc968d7e40
parent  e90f935a38bb88f37da5a3ba849531173c107413
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,29 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitCommitCheckout < Test::Unit::TestCase
0
+ def setup
0
+ @repos = mock("repos")
0
+ @repos.stubs(:url).returns("git://a.repos.com/project.git")
0
+ @reposdir = Pathname.new("tmp/.repos.tmp.git")
0
+ end
0
+
0
+ def test_clones_repository_at_indicated_path
0
+ @sha1 = "a9302"
0
+ @commit = Piston::Git::Commit.new(@repos, @sha1)
0
+ @commit.expects(:git).with(:clone, @repos.url, @reposdir)
0
+ @commit.expects(:git).with(:checkout, "-b", "my-#{@sha1}", @sha1)
0
+ Dir.expects(:chdir).with(@reposdir).yields
0
+ @commit.checkout_to(@reposdir)
0
+ end
0
+
0
+ def test_cloning_head_finds_head_commit
0
+ @sha1 = "HEAD"
0
+ @commit = Piston::Git::Commit.new(@repos, @sha1)
0
+ @commit.expects(:git).with(:clone, @repos.url, @reposdir)
0
+ @commit.expects(:git).with(:checkout, "-b", "my-#{@sha1}", @sha1)
0
+ @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")
0
+ Dir.expects(:chdir).with(@reposdir).yields
0
+ @commit.checkout_to(@reposdir)
0
+ assert_equal "922b12a6bcbb6f6a2cec60bcf5de17118086080a", @commit.revision
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,36 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+require "find"
0
+
0
+class TestGitCommitEach < Test::Unit::TestCase
0
+ def setup
0
+ @repos = mock("repository")
0
+ @repos.stubs(:url).returns("git://github.com/francois/arepos.git")
0
+
0
+ @tmpdir = Pathname.new("tmp/.arepos.tmp.git")
0
+ @tmpdir.rmtree rescue nil
0
+ @tmpdir.mkdir
0
+ @commit = Piston::Git::Commit.new(@repos, "ab"*20)
0
+ @commit.stubs(:git).returns("commit " + "ab" * 20)
0
+ @commit.checkout_to(@tmpdir)
0
+ end
0
+
0
+ def teardown
0
+ @tmpdir.rmtree
0
+ end
0
+
0
+ def test_prunes_search_tree_on_dot_git_directory
0
+ @tmpdir.expects(:find).yields(@tmpdir + ".git")
0
+ assert_throws :prune do
0
+ @commit.each do |relpath|
0
+ # Can't assert anything
0
+ end
0
+ end
0
+ end
0
+
0
+ def test_yields_paths_relative_to_working_copy
0
+ @tmpdir.expects(:find).yields(@tmpdir + "a.rb")
0
+ @commit.each do |relpath|
0
+ assert_equal Pathname.new("a.rb"), relpath
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -0,0 +1,16 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitCommitRememberance < Test::Unit::TestCase
0
+ def setup
0
+ @repos = mock("repository")
0
+ @repos.stubs(:url).returns("git://github.com/francois/arepos.git")
0
+
0
+ @reposdir = Pathname.new("tmp/repos.git")
0
+ @commit = Piston::Git::Commit.new(@repos, "ab"*20)
0
+ @values = @commit.remember_values
0
+ end
0
+
0
+ def test_remembers_original_commit
0
+ assert_equal @values[Piston::Git::COMMIT], @commit.commit
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -0,0 +1,22 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitRepositoryAt < Test::Unit::TestCase
0
+ def setup
0
+ @repos = Piston::Git::Repository.new("git://a.repos.com/project.git")
0
+ end
0
+
0
+ def test_returns_a_piston_git_commit
0
+ Piston::Git::Commit.expects(:new).with(@repos, "a93029").returns(commit = mock("commit"))
0
+ assert_equal commit, @repos.at("a93029")
0
+ end
0
+
0
+ def test_returns_a_piston_git_commit_at_head_when_appropriate
0
+ Piston::Git::Commit.expects(:new).with(@repos, "HEAD").returns(commit = mock("commit"))
0
+ assert_equal commit, @repos.at(:head)
0
+ end
0
+
0
+ def test_returns_a_git_commit_using_recalled_values
0
+ Piston::Git::Commit.expects(:new).with(@repos, "a"*40).returns(commit = mock("commit"))
0
+ assert_equal commit, @repos.at(Piston::Git::COMMIT => "a"*40)
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -0,0 +1,12 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitRepositoryBasename < Test::Unit::TestCase
0
+ def test_basename_is_urls_last_component_minus_dot_git
0
+ assert_equal "piston", basename("git://github.com/francois/piston.git")
0
+ end
0
+
0
+ private
0
+ def basename(url)
0
+ Piston::Git::Repository.new(url).basename
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -0,0 +1,22 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitRepositoryGuessing < Test::Unit::TestCase
0
+ def test_understands_git_protocol
0
+ assert Piston::Git::Repository.understands_url?("git://github.com/francois/piston.git")
0
+ end
0
+
0
+ def test_understand_http_when_heads_returned
0
+ Piston::Git::Repository.expects(:git).with("ls-remote", "--heads", "http://github.com/francois/piston.git").returns("ab"*20 + " refs/heads/master")
0
+ assert Piston::Git::Repository.understands_url?("http://github.com/francois/piston.git")
0
+ end
0
+
0
+ def test_does_not_understand_http_when_no_heads
0
+ Piston::Git::Repository.expects(:git).with("ls-remote", "--heads", "http://github.com/francois/piston.git").returns("")
0
+ deny Piston::Git::Repository.understands_url?("http://github.com/francois/piston.git")
0
+ end
0
+
0
+ def test_asks_url_when_ssh_protocol
0
+ Piston::Git::Repository.expects(:git).with("ls-remote", "--heads", "ssh://francois@github.com/francois/piston.git").returns("ab"*20 + " refs/heads/master")
0
+ assert Piston::Git::Repository.understands_url?("ssh://francois@github.com/francois/piston.git")
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,28 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitWorkingCopyCopying < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wc = Piston::Git::WorkingCopy.new(@wcdir)
0
+ @wc.stubs(:git)
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_copies_file
0
+ files = ["file.rb"]
0
+ files.expects(:copy_to).with("file.rb", @wcdir + files.first)
0
+ @wc.copy_from(files)
0
+ end
0
+
0
+ def test_ensures_directories_are_created
0
+ files = ["file/a.rb"]
0
+ @wcdir.expects(:+).with(files.first).returns(target = mock("target"))
0
+ target.expects(:dirname).returns(target)
0
+ target.expects(:mkdir)
0
+ files.expects(:copy_to).with("file/a.rb", target)
0
+ @wc.copy_from(files)
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,26 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitWorkingCopyCreation < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wcdir.rmtree rescue nil
0
+ @wc = Piston::Git::WorkingCopy.new(@wcdir)
0
+ @wc.stubs(:git)
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_create_does_a_simple_mkpath
0
+ @wcdir.expects(:mkpath)
0
+ @wc.create
0
+ end
0
+
0
+ def test_create_succeeds_even_if_mkpath_fails
0
+ @wcdir.expects(:mkpath).raises(Errno::EEXIST)
0
+ assert_nothing_raised do
0
+ @wc.create
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -0,0 +1,21 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitWorkingCopyExistence < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wc = Piston::Git::WorkingCopy.new(@wcdir)
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_exist_false_when_no_dir
0
+ deny @wc.exist?
0
+ end
0
+
0
+ def test_exist_true_when_dir_present
0
+ @wcdir.mkdir
0
+ assert @wc.exist?
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0
@@ -0,0 +1,18 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitWorkingCopyFinalization < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wc = Piston::Git::WorkingCopy.new(@wcdir)
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_finalize_adds_path_to_git
0
+ Dir.expects(:chdir).with(@wcdir).yields
0
+ @wc.expects(:git).with(:add, ".")
0
+ @wc.finalize
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,34 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitWorkingCopyGuessing < Test::Unit::TestCase
0
+ def setup
0
+ @dir = Pathname.new("tmp/wc")
0
+ end
0
+
0
+ def test_does_git_status_on_directory
0
+ Dir.expects(:chdir).with(@dir).yields
0
+ Piston::Git::WorkingCopy.expects(:git).with(:status).returns("# On branch master
0
+nothing to commit (working directory clean)
0
+")
0
+ assert Piston::Git::WorkingCopy.understands_dir?(@dir)
0
+ end
0
+
0
+ def test_does_git_status_on_parent_directories_recursively
0
+ @wc = @dir
0
+ @tmp = @wc.parent
0
+ @root = @tmp.parent
0
+
0
+ Dir.expects(:chdir).with(@dir).raises(Errno::ENOENT)
0
+ Dir.expects(:chdir).with(@tmp).raises(Errno::ENOENT)
0
+ Dir.expects(:chdir).with(@root).yields
0
+ Piston::Git::WorkingCopy.expects(:git).with(:status).returns("# On branch master
0
+nothing to commit (working directory clean)
0
+")
0
+ assert Piston::Git::WorkingCopy.understands_dir?(@dir)
0
+ end
0
+
0
+ def test_denies_when_git_unavailable
0
+ Piston::Git::WorkingCopy.stubs(:git).raises(Piston::Git::Client::BadCommand)
0
+ deny Piston::Git::WorkingCopy.understands_dir?(@dir)
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,25 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitWorkingCopyRememberance < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wcdir.mkdir rescue nil
0
+ @wc = Piston::Git::WorkingCopy.new(@wcdir)
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree
0
+ end
0
+
0
+ def test_creates_dot_piston_dot_yml_file
0
+ @wc.remember({}, "a" => "b")
0
+ assert((@wcdir + ".piston.yml").exist?)
0
+ end
0
+
0
+ def test_writes_values_as_yaml_under_handler_key
0
+ expected = {"a" => "b"}
0
+ @wc.remember({}, expected)
0
+ actual = YAML.load((@wcdir + ".piston.yml").read)
0
+ assert_equal expected, actual["handler"]
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0
@@ -0,0 +1,18 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnRepositoryAt < Test::Unit::TestCase
0
+ def setup
0
+ @repos = Piston::Svn::Repository.new("http://bla.com/svn/repos/trunk")
0
+ end
0
+
0
+ def test_instantiate_revision_at_head
0
+ Piston::Svn::Revision.expects(:new).with(@repos, "HEAD").returns(:newrev)
0
+ assert_equal :newrev, @repos.at(:head)
0
+ end
0
+
0
+ def test_instantiate_revision_using_recalled_values
0
+ Piston::Svn::Revision.expects(:new).with(@repos, 9123).returns(:newrev)
0
+ assert_equal :newrev, @repos.at(Piston::Svn::REMOTE_REV => 9123,
0
+ Piston::Svn::UUID => "5ecf4fe2-1ee6-0310-87b1-e25e094e27de")
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0
@@ -0,0 +1,24 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnRepositoryBasename < Test::Unit::TestCase
0
+ def test_basename_is_urls_path_last_component
0
+ assert_equal "piston", basename("http://svn.rubyforge.org/var/svn/piston")
0
+ end
0
+
0
+ def test_basename_is_urls_path_last_component_minus_trunk
0
+ assert_equal "attachment_fu", basename("svn+ssh://some.host.com/svn/attachment_fu/trunk")
0
+ end
0
+
0
+ def test_basename_is_urls_path_last_component_before_branches
0
+ assert_equal "rails", basename("svn://some.host.com/svn/rails/branches/stable")
0
+ end
0
+
0
+ def test_basename_is_urls_path_last_component_before_tags
0
+ assert_equal "plugin", basename("https://some.host.com/svn/plugin/tags/stable")
0
+ end
0
+
0
+ private
0
+ def basename(url)
0
+ Piston::Svn::Repository.new(url).basename
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,45 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnRepositoryGuessing < Test::Unit::TestCase
0
+ def test_guesses_with_svn_protocol
0
+ assert Piston::Svn::Repository.understands_url?("svn://a.host.com/")
0
+ end
0
+
0
+ def test_guesses_with_svn_plus_bla_protocol
0
+ assert Piston::Svn::Repository.understands_url?("svn+bla://username@a.host.com/")
0
+ end
0
+
0
+ def test_guesses_with_svn_plus_ssh_protocol
0
+ assert Piston::Svn::Repository.understands_url?("svn+ssh://username@a.host.com/")
0
+ end
0
+
0
+ def test_contacts_repository_for_file_protocol
0
+ url = "file:///home/username/svn/projects/trunk"
0
+ Piston::Svn::Repository.expects(:svn).with(:info, url).returns("Repository UUID: abcdef\n")
0
+ assert Piston::Svn::Repository.understands_url?(url)
0
+ end
0
+
0
+ def test_contacts_repository_for_http_protocol
0
+ url = "http://svn.collab.net/repos/svn/trunk"
0
+ Piston::Svn::Repository.expects(:svn).with(:info, url).returns("Repository UUID: abcdef\n")
0
+ assert Piston::Svn::Repository.understands_url?(url)
0
+ end
0
+
0
+ def test_contacts_repository_for_https_protocol
0
+ url = "https://svn.collab.net/repos/svn/trunk"
0
+ Piston::Svn::Repository.expects(:svn).with(:info, url).returns("Repository UUID: abcdef\n")
0
+ assert Piston::Svn::Repository.understands_url?(url)
0
+ end
0
+
0
+ def test_says_does_not_understand_when_svn_info_errors_out
0
+ url = "http://rubyonrails.org/"
0
+ Piston::Svn::Repository.expects(:svn).with(:info, url).raises(Piston::Svn::Client::Failed)
0
+ deny Piston::Svn::Repository.understands_url?(url)
0
+ end
0
+
0
+ def test_says_does_not_understand_when_svn_command_not_found
0
+ url = "http://rubyonrails.org/"
0
+ Piston::Svn::Repository.expects(:svn).with(:info, url).raises(Piston::Svn::Client::BadCommand)
0
+ deny Piston::Svn::Repository.understands_url?(url)
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,27 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnRevisionCheckout < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @repos = mock("repository")
0
+ @repos.stubs(:url).returns("http://a.repos.com/trunk")
0
+ end
0
+
0
+ def test_head_checkout_to_path
0
+ rev = new_revision("HEAD")
0
+ rev.expects(:svn).with(:checkout, "--revision", "HEAD", @repos.url, @wcdir).returns("Checked out revision 1322.")
0
+ rev.checkout_to(@wcdir)
0
+ assert_equal 1322, rev.revision
0
+ end
0
+
0
+ def test_specific_revision_checkout_to_path
0
+ rev = new_revision(1231)
0
+ rev.expects(:svn).with(:checkout, "--revision", 1231, @repos.url, @wcdir).returns("Checked out revision 1231.")
0
+ rev.checkout_to(@wcdir)
0
+ end
0
+
0
+ private
0
+ def new_revision(revision)
0
+ Piston::Svn::Revision.new(@repos, revision)
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -0,0 +1,21 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnRevisionEach < Test::Unit::TestCase
0
+ def setup
0
+ @repos = mock("repository")
0
+ @repos.stubs(:url).returns("http://a.repos.com/project/trunk")
0
+
0
+ @wcdir = Pathname.new("tmp/.wc.tmp")
0
+
0
+ @rev = Piston::Svn::Revision.new(@repos, "HEAD")
0
+ @rev.stubs(:svn).returns("Checked out revision 111.\n")
0
+ @rev.checkout_to(@wcdir)
0
+ end
0
+
0
+ def test_each_skips_over_svn_metadata_folders
0
+ @rev.expects(:svn).with(:ls, "--recursive", @wcdir).returns("CONTRIBUTORS\nREADME\ntest/test_helper.rb\n")
0
+ expected = ["CONTRIBUTORS", "README", "test/test_helper.rb"]
0
+ actual = @rev.inject([]) {|memo, relpath| memo << relpath}
0
+ assert_equal expected.sort, actual.sort
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,42 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnRevisionRememberance < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wcdir.mkdir rescue nil
0
+ @repos = mock("repository")
0
+ @repos.stubs(:url).returns("http://a.repos.com/svn/trunk")
0
+
0
+ @info = {"Path" => @wcdir.realpath,
0
+ "URL" => "http://a.repos.com/svn/trunk",
0
+ "Repository Root" => "http://a.repos.com/svn",
0
+ "Repository UUID" => "some-long-uuid",
0
+ "Revision" => "9283",
0
+ "Node Kind" => "directory",
0
+ "Schedule" => "normal",
0
+ "Last Changed Author" => "me",
0
+ "Last Changed Rev" => "9283",
0
+ "Last Changed Date" => "2008-03-11 20:44:24 -0400 (Tue, 11 Mar 2008)"}
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_remembers_repos_uuid
0
+ rev = new_revision("HEAD")
0
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repos.url).returns(@info.to_yaml)
0
+ assert_equal "some-long-uuid", rev.remember_values[Piston::Svn::UUID]
0
+ end
0
+
0
+ def test_remembers_repos_revision
0
+ rev = new_revision("HEAD")
0
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repos.url).returns(@info.to_yaml)
0
+ assert_equal "9283", rev.remember_values[Piston::Svn::REMOTE_REV]
0
+ end
0
+
0
+ private
0
+ def new_revision(revision)
0
+ Piston::Svn::Revision.new(@repos, revision)
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,29 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnWorkingCopyCopying < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
0
+ @wc.stubs(:svn)
0
+ @wc.stubs(:svn).with(:info, anything).returns("a:b")
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_copies_files
0
+ files = ["file.rb"]
0
+ files.expects(:copy_to).with("file.rb", @wcdir + files.first)
0
+ @wc.copy_from(files)
0
+ end
0
+
0
+ def test_ensures_directories_are_created
0
+ files = ["file/a.rb"]
0
+ @wcdir.expects(:+).with(files.first).returns(target = mock("target"))
0
+ target.expects(:dirname).returns(target)
0
+ target.expects(:mkdir)
0
+ files.expects(:copy_to).with("file/a.rb", target)
0
+ @wc.copy_from(files)
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
0
@@ -0,0 +1,19 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnWorkingCopyCreation < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
0
+ @wc.stubs(:svn)
0
+ @wc.stubs(:svn).with(:info, anything).returns("a:b")
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_create_uses_svn_mkdir
0
+ @wc.expects(:svn).with(:mkdir, @wcdir)
0
+ @wc.create
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,26 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnWorkingCopyExistence < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_exist_false_when_dir_not_present
0
+ deny @wc.exist?
0
+ end
0
+
0
+ def test_exist_false_when_dir_present_but_not_an_svn_wc
0
+ @wcdir.mkdir
0
+ deny @wc.exist?
0
+ end
0
+
0
+ def test_exist_true_when_svn_working_copy_at_path
0
+ @wc.expects(:svn).with(:info, @wcdir).returns("Path: b")
0
+ assert @wc.exist?
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -0,0 +1,21 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnWorkingCopyFinalization < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_finalize_adds_all_top_level_entries_to_working_copy
0
+ @wcdir.mkdir
0
+ File.open(@wcdir + "a.rb", "wb") {|f| f.write "Hello World!"}
0
+ File.open(@wcdir + "b.rb", "wb") {|f| f.write "Hello World!"}
0
+ @wc.expects(:svn).with(:add, (@wcdir + "a.rb").to_s)
0
+ @wc.expects(:svn).with(:add, (@wcdir + "b.rb").to_s)
0
+ @wc.finalize
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -0,0 +1,17 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnWorkingCopyGuessing < Test::Unit::TestCase
0
+ def setup
0
+ @dir = Pathname.new("tmp/wc")
0
+ end
0
+
0
+ def test_does_svn_info_on_directory
0
+ Piston::Svn::WorkingCopy.expects(:svn).with(:info, @dir).returns("Path: xxx\n")
0
+ assert Piston::Svn::WorkingCopy.understands_dir?(@dir)
0
+ end
0
+
0
+ def test_denies_when_svn_not_available
0
+ Piston::Svn::WorkingCopy.expects(:svn).with(:info, @dir).raises(Piston::Svn::Client::BadCommand)
0
+ deny Piston::Svn::WorkingCopy.understands_dir?(@dir)
0