public
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
Search Repo:
Moved the unit tests into their own namespace.

New rake task to run just the unit tests.
francois (author)
Sat Mar 22 19:16:14 -0700 2008
commit  5974519381b76cb2e8ad4334f4d9f8682ae6f3fd
tree    1fae6bd4fbbfd8b31882bfcfae1b53bbb2330dc0
parent  a7b5e41f15645c99f97f370904c28a9f57bc8e7b
...
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1 +1,11 @@
0
+require "rake/testtask"
0
+
0
+namespace :test do
0
+ Rake::TestTask.new("units") do |t|
0
+ t.libs << "test"
0
+ t.test_files = FileList['test/unit/**/test_*.rb']
0
+ t.verbose = true
0
+ t.warning = true
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
@@ -1,30 +1 @@
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
@@ -1,37 +1 @@
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
17
18
19
20
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,21 +1 @@
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_repository_url
0
- assert_equal @repos.url, @values[Piston::Git::URL]
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
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,18 +1 @@
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
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,23 +1 @@
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
@@ -1,29 +1 @@
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
@@ -1,27 +1 @@
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
@@ -1,22 +1 @@
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
@@ -1,19 +1 @@
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
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,32 +1 @@
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
- Piston::Git::WorkingCopy.expects(:git).with(:status, @dir).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
- Piston::Git::WorkingCopy.expects(:git).with(:status, @wc)
0
- Piston::Git::WorkingCopy.expects(:git).with(:status, @tmp)
0
- Piston::Git::WorkingCopy.expects(:git).with(:status, @root).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
@@ -1,26 +1 @@
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
@@ -1,19 +1 @@
0
-require File.dirname(__FILE__) + "/test_helper"
0
-
0
-class TestImport < Test::Unit::TestCase
0
- def setup
0
- @wc = stub_everything("working_copy")
0
- @cmd = Piston::Commands::Import.new
0
- @cmd.stubs(:debug)
0
- @cmd.stubs(:info)
0
- @cmd.stubs(:warn)
0
- @cmd.stubs(:error)
0
- @cmd.stubs(:fatal)
0
- end
0
-
0
- def test_temp_dir_name_hides_tmpdir_as_a_dotfile_and_suffixes_with_tmp
0
- @wc.stubs(:path).returns(Pathname.new("tmp/a/dir"))
0
- assert_equal Pathname.new("tmp/a/.dir.tmp"), @cmd.temp_dir_name(@wc)
0
- end
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
...
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,12 +1 @@
0
-require File.dirname(__FILE__) + '/test_helper.rb'
0
-
0
-class TestPiston < Test::Unit::TestCase
0
-
0
- def setup
0
- end
0
-
0
- def test_truth
0
- assert true
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
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,34 +1 @@
0
-require File.dirname(__FILE__) + "/test_helper"
0
-
0
-class TestRepositoryGuessing < Test::Unit::TestCase
0
- def setup
0
- Piston::Repository.send(:handlers).clear
0
- end
0
-
0
- def test_guess_when_no_handlers_raises
0
- assert_raise Piston::Repository::UnhandledUrl do
0
- Piston::Repository.guess("http://")
0
- end
0
- end
0
-
0
- def test_guess_asks_each_handler_in_turn
0
- Piston::Repository.add_handler(handler = mock("handler"))
0
- handler.expects(:understands_url?).with("http://a.repos.com/trunk").returns(false)
0
- assert_raise Piston::Repository::UnhandledUrl do
0
- Piston::Repository.guess("http://a.repos.com/trunk")
0
- end
0
- end
0
-
0
- def test_guess_returns_first_handler_that_understands_the_url
0
- url = "svn://a.repos.com/projects/libcalc/trunk"
0
-
0
- handler = mock("handler")
0
- handler.expects(:understands_url?).with(url).returns(true)
0
- handler_instance = mock("handler_instance")
0
- handler.expects(:new).with(url).returns(handler_instance)
0
-
0
- Piston::Repository.add_handler handler
0
- assert_equal handler_instance, Piston::Repository.guess(url)
0
- end
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
...
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,13 +1 @@
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
-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
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,40 +1 @@
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_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
@@ -1,28 +1 @@
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
@@ -1,22 +1 @@
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
43
44
45
46
47
48
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,49 +1 @@
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_url
0
- rev = new_revision("HEAD")
0
- rev.expects(:svn).with(:info, "--revision", "HEAD", @repos.url).returns(@info.to_yaml)
0
- assert_equal @repos.url, rev.remember_values[Piston::Svn::ROOT]
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
@@ -1,30 +1 @@
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
@@ -1,20 +1 @@
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
@@ -1,27 +1 @@
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