piston 1.4.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +24 -0
- data/License.txt +20 -0
- data/Manifest.txt +109 -0
- data/{README → README.txt} +14 -10
- data/VERSION.yml +4 -0
- data/bin/piston +3 -8
- data/lib/piston/cli.rb +121 -0
- data/lib/piston/commands/base.rb +44 -0
- data/lib/piston/commands/convert.rb +23 -71
- data/lib/piston/commands/diff.rb +14 -46
- data/lib/piston/commands/import.rb +48 -57
- data/lib/piston/commands/info.rb +24 -0
- data/lib/piston/commands/lock_unlock.rb +26 -0
- data/lib/piston/commands/status.rb +29 -54
- data/lib/piston/commands/update.rb +35 -122
- data/lib/piston/commands/upgrade.rb +26 -0
- data/lib/piston/commands.rb +4 -0
- data/lib/piston/git/client.rb +76 -0
- data/lib/piston/git/commit.rb +114 -0
- data/lib/piston/git/repository.rb +63 -0
- data/lib/piston/git/working_copy.rb +145 -0
- data/lib/piston/git.rb +13 -0
- data/lib/piston/repository.rb +61 -0
- data/lib/piston/revision.rb +83 -0
- data/lib/piston/svn/client.rb +88 -0
- data/lib/piston/svn/repository.rb +67 -0
- data/lib/piston/svn/revision.rb +112 -0
- data/lib/piston/svn/working_copy.rb +184 -0
- data/lib/piston/svn.rb +15 -0
- data/lib/piston/version.rb +9 -7
- data/lib/piston/working_copy.rb +334 -0
- data/lib/piston.rb +13 -64
- data/lib/subclass_responsibility_error.rb +2 -0
- data/test/integration_helpers.rb +36 -0
- data/test/spec_suite.rb +4 -0
- data/test/test_helper.rb +92 -0
- data/test/unit/git/commit/test_checkout.rb +31 -0
- data/test/unit/git/commit/test_each.rb +30 -0
- data/test/unit/git/commit/test_rememberance.rb +22 -0
- data/test/unit/git/commit/test_validation.rb +34 -0
- data/test/unit/git/repository/test_at.rb +23 -0
- data/test/unit/git/repository/test_basename.rb +12 -0
- data/test/unit/git/repository/test_branchanme.rb +15 -0
- data/test/unit/git/repository/test_guessing.rb +32 -0
- data/test/unit/git/working_copy/test_copying.rb +25 -0
- data/test/unit/git/working_copy/test_creation.rb +22 -0
- data/test/unit/git/working_copy/test_existence.rb +18 -0
- data/test/unit/git/working_copy/test_finalization.rb +15 -0
- data/test/unit/git/working_copy/test_guessing.rb +35 -0
- data/test/unit/git/working_copy/test_rememberance.rb +22 -0
- data/test/unit/svn/repository/test_at.rb +19 -0
- data/test/unit/svn/repository/test_basename.rb +24 -0
- data/test/unit/svn/repository/test_guessing.rb +45 -0
- data/test/unit/svn/revision/test_checkout.rb +28 -0
- data/test/unit/svn/revision/test_each.rb +22 -0
- data/test/unit/svn/revision/test_rememberance.rb +38 -0
- data/test/unit/svn/revision/test_validation.rb +50 -0
- data/test/unit/svn/working_copy/test_copying.rb +26 -0
- data/test/unit/svn/working_copy/test_creation.rb +16 -0
- data/test/unit/svn/working_copy/test_existence.rb +23 -0
- data/test/unit/svn/working_copy/test_externals.rb +56 -0
- data/test/unit/svn/working_copy/test_finalization.rb +17 -0
- data/test/unit/svn/working_copy/test_guessing.rb +18 -0
- data/test/unit/svn/working_copy/test_rememberance.rb +26 -0
- data/test/unit/test_info.rb +37 -0
- data/test/unit/test_lock_unlock.rb +47 -0
- data/test/unit/test_repository.rb +51 -0
- data/test/unit/test_revision.rb +31 -0
- data/test/unit/working_copy/test_guessing.rb +35 -0
- data/test/unit/working_copy/test_info.rb +14 -0
- data/test/unit/working_copy/test_rememberance.rb +42 -0
- data/test/unit/working_copy/test_validate.rb +63 -0
- metadata +132 -31
- data/CHANGELOG +0 -81
- data/LICENSE +0 -19
- data/Rakefile +0 -63
- data/contrib/piston +0 -43
- data/lib/core_ext/range.rb +0 -5
- data/lib/core_ext/string.rb +0 -9
- data/lib/piston/command.rb +0 -68
- data/lib/piston/command_error.rb +0 -6
- data/lib/piston/commands/lock.rb +0 -30
- data/lib/piston/commands/switch.rb +0 -139
- data/lib/piston/commands/unlock.rb +0 -29
- data/lib/transat/parser.rb +0 -189
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
|
2
|
+
|
3
|
+
class Piston::Svn::TestSvnRevisionValidation < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@repository = mock("repository")
|
7
|
+
@repository.stubs(:url).returns("svn://svn.my-repos.com/projects/libcalc/trunk")
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_revision_is_invalid_unless_same_uuid
|
11
|
+
rev = new_revision("HEAD", Piston::Svn::UUID => "1234")
|
12
|
+
rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns(INFO)
|
13
|
+
assert_raise Piston::Svn::Revision::UuidChanged do
|
14
|
+
rev.validate!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_revision_is_invalid_if_repository_location_does_not_exist_anymore
|
19
|
+
rev = new_revision("HEAD", Piston::Svn::UUID => "038cbeb6-2227-0410-91ec-8f9533625906")
|
20
|
+
rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns("#{@repository.url}: (Not a valid URL)")
|
21
|
+
assert_raise Piston::Svn::Revision::RepositoryMoved do
|
22
|
+
rev.validate!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_revision_is_valid_if_repository_is_present_and_same_uuid
|
27
|
+
rev = new_revision("HEAD", Piston::Svn::UUID => "038cbeb6-2227-0410-91ec-8f9533625906")
|
28
|
+
rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns(INFO)
|
29
|
+
assert_nothing_raised do
|
30
|
+
rev.validate!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
def new_revision(rev, recalled_values={})
|
36
|
+
Piston::Svn::Revision.new(@repository, rev, recalled_values)
|
37
|
+
end
|
38
|
+
|
39
|
+
INFO = <<EOF
|
40
|
+
Path: project
|
41
|
+
URL: svn://svn.my-repos.com/projects/libcalc/trunk
|
42
|
+
Repository Root: svn://svn.my-repos.com/projects
|
43
|
+
Repository UUID: 038cbeb6-2227-0410-91ec-8f9533625906
|
44
|
+
Revision: 1234
|
45
|
+
Node Kind: directory
|
46
|
+
Last Changed Author: francois
|
47
|
+
Last Changed Rev: 1232
|
48
|
+
Last Changed Date: 2008-04-06 21:57:10 -0400 (Sun, 06 Apr 2008)
|
49
|
+
EOF
|
50
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
|
2
|
+
|
3
|
+
class Piston::Svn::TestSvnWorkingCopyCopying < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@wcdir = mkpath("tmp/wc")
|
7
|
+
@wc = Piston::Svn::WorkingCopy.new(@wcdir)
|
8
|
+
@wc.stubs(:svn)
|
9
|
+
@wc.stubs(:svn).with(:info, anything).returns("a:b")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_copies_files
|
13
|
+
files = ["file.rb"]
|
14
|
+
files.expects(:copy_to).with("file.rb", @wcdir + files.first)
|
15
|
+
@wc.copy_from(files)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_ensures_directories_are_created
|
19
|
+
files = ["file/a.rb"]
|
20
|
+
@wcdir.expects(:+).with(files.first).returns(target = mock("target"))
|
21
|
+
target.expects(:dirname).returns(target)
|
22
|
+
target.expects(:mkdir)
|
23
|
+
files.expects(:copy_to).with("file/a.rb", target)
|
24
|
+
@wc.copy_from(files)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
|
2
|
+
|
3
|
+
class Piston::Svn::TestSvnWorkingCopyCreation < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@wcdir = mkpath("tmp/wc")
|
7
|
+
@wc = Piston::Svn::WorkingCopy.new(@wcdir)
|
8
|
+
@wc.stubs(:svn)
|
9
|
+
@wc.stubs(:svn).with(:info, anything).returns("a:b")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_create_uses_svn_mkdir
|
13
|
+
@wc.expects(:svn).with(:mkdir, @wcdir)
|
14
|
+
@wc.create
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
|
2
|
+
|
3
|
+
class Piston::Svn::TestSvnWorkingCopyExistence < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@wcdir = Pathname.new(File.expand_path("tmp/wc"))
|
7
|
+
@wc = Piston::Svn::WorkingCopy.new(@wcdir)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_exist_false_when_dir_not_present
|
11
|
+
deny @wc.exist?
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_exist_false_when_dir_present_but_not_an_svn_wc
|
15
|
+
@wcdir.mkpath
|
16
|
+
deny @wc.exist?
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_exist_true_when_svn_working_copy_at_path
|
20
|
+
@wc.expects(:svn).with(:info, @wcdir).returns("Path: b")
|
21
|
+
assert @wc.exist?
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
|
2
|
+
|
3
|
+
class Piston::Svn::TestWorkingCopyExternals < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@wcdir = mkpath("tmp/wc")
|
7
|
+
@wc = Piston::Svn::WorkingCopy.new(@wcdir)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_parse_empty_svn_externals
|
11
|
+
@wc.stubs(:svn).returns(EMPTY_EXTERNALS)
|
12
|
+
assert_equal({}, @wc.externals)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_parse_simple_externals
|
16
|
+
@wc.stubs(:svn).returns(SIMPLE_RAILS_EXTERNALS)
|
17
|
+
assert_equal({@wcdir + "vendor/rails" => {:revision => :head, :url => "http://dev.rubyonrails.org/svn/rails/trunk"}}, @wc.externals)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_parse_externals_with_revision
|
21
|
+
@wc.stubs(:svn).returns(VERSIONED_RAILS_EXTERNALS)
|
22
|
+
assert_equal({@wcdir + "vendor/rails" => {:revision => 8726, :url => "http://dev.rubyonrails.org/svn/rails/trunk"}}, @wc.externals)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_parse_externals_with_long_revision
|
26
|
+
@wc.stubs(:svn).returns(LONG_VERSION_RAILS_EXTERNALS)
|
27
|
+
assert_equal({@wcdir + "vendor/rails" => {:revision => 8726, :url => "http://dev.rubyonrails.org/svn/rails/trunk"}}, @wc.externals)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_remove_external_references_calls_svn_propdel
|
31
|
+
@wc.expects(:svn).with(:propdel, "svn:externals", @wcdir+"vendor")
|
32
|
+
@wc.remove_external_references(@wcdir+"vendor")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_remove_external_references_calls_svn_propdel_with_multiple_dirs
|
36
|
+
@wc.expects(:svn).with(:propdel, "svn:externals", @wcdir+"vendor", @wcdir+"vendor/plugins")
|
37
|
+
@wc.remove_external_references(@wcdir+"vendor", @wcdir+"vendor/plugins")
|
38
|
+
end
|
39
|
+
|
40
|
+
EMPTY_EXTERNALS = ""
|
41
|
+
SIMPLE_RAILS_EXTERNALS = <<EOF
|
42
|
+
Properties on 'vendor':
|
43
|
+
svn:externals : rails http://dev.rubyonrails.org/svn/rails/trunk
|
44
|
+
|
45
|
+
EOF
|
46
|
+
VERSIONED_RAILS_EXTERNALS = <<EOF
|
47
|
+
Properties on 'vendor':
|
48
|
+
svn:externals : rails -r8726 http://dev.rubyonrails.org/svn/rails/trunk
|
49
|
+
|
50
|
+
EOF
|
51
|
+
LONG_VERSION_RAILS_EXTERNALS = <<EOF
|
52
|
+
Properties on 'vendor':
|
53
|
+
svn:externals : rails --revision 8726 http://dev.rubyonrails.org/svn/rails/trunk
|
54
|
+
|
55
|
+
EOF
|
56
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
|
2
|
+
|
3
|
+
class Piston::Svn::TestSvnWorkingCopyFinalization < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@wcdir = mkpath("tmp/wc")
|
7
|
+
@wc = Piston::Svn::WorkingCopy.new(@wcdir)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_finalize_adds_all_top_level_entries_to_working_copy
|
11
|
+
File.open(@wcdir + "a.rb", "wb") {|f| f.write "Hello World!"}
|
12
|
+
File.open(@wcdir + "b.rb", "wb") {|f| f.write "Hello World!"}
|
13
|
+
@wc.expects(:svn).with(:add, (@wcdir + "a.rb").to_s)
|
14
|
+
@wc.expects(:svn).with(:add, (@wcdir + "b.rb").to_s)
|
15
|
+
@wc.finalize
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
|
2
|
+
|
3
|
+
class Piston::Svn::TestSvnWorkingCopyGuessing < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@dir = mkpath("tmp/wc")
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_does_svn_info_on_directory
|
10
|
+
Piston::Svn::WorkingCopy.expects(:svn).with(:info, @dir).returns("Path: xxx\n")
|
11
|
+
assert Piston::Svn::WorkingCopy.understands_dir?(@dir)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_denies_when_svn_not_available
|
15
|
+
Piston::Svn::WorkingCopy.expects(:svn).with(:info, @dir).raises(Piston::Svn::Client::BadCommand)
|
16
|
+
deny Piston::Svn::WorkingCopy.understands_dir?(@dir)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
|
2
|
+
|
3
|
+
class Piston::Svn::TestSvnWorkingCopyRememberance < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@wcdir = mkpath("tmp/wc")
|
7
|
+
@wc = Piston::Svn::WorkingCopy.new(@wcdir)
|
8
|
+
@wc.stubs(:svn)
|
9
|
+
@wc.stubs(:svn).with(:info, anything).returns("a:b")
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
@wcdir.rmtree rescue nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_after_remember_adds_path_using_svn
|
17
|
+
@wc.expects(:svn).with(:info, :the_path).returns("a: (Not a versioned resource)\n")
|
18
|
+
@wc.expects(:svn).with(:add, :the_path)
|
19
|
+
@wc.after_remember(:the_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_after_remember_does_not_add_if_file_already_under_version_control
|
23
|
+
@wc.expects(:svn).with(:info, :the_path).returns("a: b\n")
|
24
|
+
@wc.after_remember(:the_path)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
2
|
+
|
3
|
+
class TestInfo < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@values = {"lock" => false}
|
7
|
+
@wcdir = "tmp/wcdir"
|
8
|
+
@wc = mock("WorkingCopy")
|
9
|
+
@wc.stubs(:validate!)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_info
|
13
|
+
run_and_verify do
|
14
|
+
@wc.expects(:info)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_validates_working_copy_before_working
|
19
|
+
assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
|
20
|
+
run_and_verify do
|
21
|
+
@wc.expects(:validate!).raises(Piston::WorkingCopy::NotWorkingCopy)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def run_and_verify
|
28
|
+
yield
|
29
|
+
info_command.run(@wcdir)
|
30
|
+
end
|
31
|
+
|
32
|
+
def info_command
|
33
|
+
Piston::WorkingCopy.expects(:guess).with(@wcdir).returns(@wc)
|
34
|
+
Piston::Commands::Info.new(:verbose => "verbose",
|
35
|
+
:quiet => "quiet", :force => "force")
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
2
|
+
|
3
|
+
class TestLockUnlock < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@values = {"lock" => false}
|
7
|
+
@wcdir = "tmp/wcdir"
|
8
|
+
@wc = mock("WorkingCopy")
|
9
|
+
@wc.stubs(:validate!)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_lock_working_copy
|
13
|
+
run_and_verify(true) do
|
14
|
+
@wc.expects(:recall).returns(@values)
|
15
|
+
@wc.expects(:finalize).returns(@values)
|
16
|
+
@wc.expects(:remember).with(@values.merge("lock" => true), @values["handler"]).returns(@values)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_unlock_working_copy
|
21
|
+
run_and_verify(false) do
|
22
|
+
@wc.expects(:recall).returns(@values)
|
23
|
+
@wc.expects(:finalize).returns(@values)
|
24
|
+
@wc.expects(:remember).with(@values.merge("lock" => false), @values["handler"]).returns(@values)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_validates_working_copy_before_working
|
29
|
+
assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
|
30
|
+
run_and_verify do
|
31
|
+
@wc.expects(:validate!).raises(Piston::WorkingCopy::NotWorkingCopy)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def run_and_verify(lock=true)
|
38
|
+
yield
|
39
|
+
lock_unlock_command.run(lock)
|
40
|
+
end
|
41
|
+
|
42
|
+
def lock_unlock_command
|
43
|
+
Piston::WorkingCopy.expects(:guess).with(File.expand_path(@wcdir)).returns(@wc)
|
44
|
+
Piston::Commands::LockUnlock.new(:verbose => "verbose", :wcdir => @wcdir,
|
45
|
+
:quiet => "quiet", :force => "force")
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
2
|
+
|
3
|
+
class TestRepository < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
Piston::Repository.send(:handlers).clear
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_guess_asks_each_handler_in_turn
|
10
|
+
Piston::Repository.add_handler(handler = mock("handler"))
|
11
|
+
handler.expects(:understands_url?).with("http://a.repos.com/trunk").returns(false)
|
12
|
+
assert_raise Piston::Repository::UnhandledUrl do
|
13
|
+
Piston::Repository.guess("http://a.repos.com/trunk")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_guess_returns_first_handler_that_understands_the_url
|
18
|
+
url = "svn://a.repos.com/projects/libcalc/trunk"
|
19
|
+
|
20
|
+
handler = mock("handler")
|
21
|
+
handler.expects(:understands_url?).with(url).returns(true)
|
22
|
+
handler_instance = mock("handler_instance")
|
23
|
+
handler.expects(:new).with(url).returns(handler_instance)
|
24
|
+
|
25
|
+
Piston::Repository.add_handler handler
|
26
|
+
assert_equal handler_instance, Piston::Repository.guess(url)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_guess_raises_unhandled_url_exception_when_no_repository_handler_found
|
30
|
+
assert_raise(Piston::Repository::UnhandledUrl) do
|
31
|
+
Piston::Repository.guess("invalid")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_add_handler
|
36
|
+
Piston::Repository.add_handler(handler = mock("handler"))
|
37
|
+
assert_equal [handler], Piston::Repository.send(:handlers)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_initialize_stores_url_parameter_in_url_accessor
|
41
|
+
@repository = Piston::Repository.new("url")
|
42
|
+
assert_equal "url", @repository.url
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_at_is_a_subclass_responsibility
|
46
|
+
@repository = Piston::Repository.new("url")
|
47
|
+
assert_raise(SubclassResponsibilityError) do
|
48
|
+
@repository.at(:any)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
2
|
+
|
3
|
+
class TestRevision < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@repository = mock("repository")
|
7
|
+
@revision_number = "1"
|
8
|
+
@revision = Piston::Revision.new(@repository, @revision_number)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_initialize
|
12
|
+
assert_equal @repository, @revision.repository
|
13
|
+
assert_equal @revision_number, @revision.revision
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_repository
|
17
|
+
assert_equal @repository, @revision.repository
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_revision
|
21
|
+
assert_equal @revision_number, @revision.revision
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_name
|
25
|
+
assert_equal @revision_number, @revision.name
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_default_recalled_values_are_an_empty_hash
|
29
|
+
assert_equal Hash.new, @revision.recalled_values
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../test_helper")
|
2
|
+
|
3
|
+
class TestWorkingCopyGuessing < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
Piston::WorkingCopy.send(:handlers).clear
|
7
|
+
@dir = mkpath("tmp/wc")
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_guess_when_no_handlers_raises
|
11
|
+
assert_raise Piston::WorkingCopy::UnhandledWorkingCopy do
|
12
|
+
Piston::WorkingCopy.guess(@dir)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_guess_asks_each_handler_in_turn
|
17
|
+
Piston::WorkingCopy.add_handler(handler = mock("handler"))
|
18
|
+
handler.stubs(:name).returns("aname")
|
19
|
+
handler.expects(:understands_dir?).with(@dir).returns(false)
|
20
|
+
assert_raise Piston::WorkingCopy::UnhandledWorkingCopy do
|
21
|
+
Piston::WorkingCopy.guess(@dir)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_guess_returns_first_handler_that_understands_the_url
|
26
|
+
handler = mock("handler")
|
27
|
+
handler.stubs(:name).returns("aname")
|
28
|
+
handler.expects(:understands_dir?).with(@dir).returns(true)
|
29
|
+
handler_instance = mock("handler_instance")
|
30
|
+
handler.expects(:new).with(File.expand_path(@dir)).returns(handler_instance)
|
31
|
+
|
32
|
+
Piston::WorkingCopy.add_handler handler
|
33
|
+
assert_equal handler_instance, Piston::WorkingCopy.guess(@dir)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../test_helper")
|
2
|
+
|
3
|
+
class TestWorkingCopyInfo < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@path = mkpath("tmp/wc")
|
7
|
+
@wc = Piston::WorkingCopy.new(@path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_info_recalls_values
|
11
|
+
@wc.expects(:recall).returns(values = mock("recalled values"))
|
12
|
+
assert_equal values, @wc.info
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../test_helper")
|
2
|
+
|
3
|
+
class TestWorkingCopyRememberance < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@wcdir = mkpath("tmp/wc")
|
7
|
+
@wc = Piston::WorkingCopy.new(@wcdir)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_remember_generates_piston_yml_file_in_wc
|
11
|
+
@wc.remember({}, "a" => "b")
|
12
|
+
assert((@wcdir + ".piston.yml").exist?, "tmp/wc/.piston.yml file doesn't exist")
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_writes_values_as_yaml_under_handler_key
|
16
|
+
expected = {"a" => "b"}
|
17
|
+
@wc.remember({}, expected)
|
18
|
+
actual = YAML.load_file(@wcdir + ".piston.yml")
|
19
|
+
assert_equal expected, actual["handler"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_remember_calls_after_remember_with_path_to_piston_yml_file
|
23
|
+
@wc.expects(:after_remember).with(Pathname.new(@wcdir + ".piston.yml"))
|
24
|
+
@wc.remember({}, "a" => "b")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_remember_with_two_args_remembers_handler_values_separately
|
28
|
+
values = {"lock" => true}
|
29
|
+
handler_values = {"a" => "b"}
|
30
|
+
|
31
|
+
@wc.remember(values, handler_values)
|
32
|
+
|
33
|
+
actual = YAML.load_file(@wcdir + ".piston.yml")
|
34
|
+
assert_equal values.merge("format" => 1, "handler" => handler_values), actual
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_recall_returns_hash_of_values
|
38
|
+
values = {"a" => "b", "handler" => {"b" => "c"}}
|
39
|
+
YAML.expects(:load_file).with(@wcdir + ".piston.yml").returns(values)
|
40
|
+
assert_equal values, @wc.recall
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../test_helper")
|
2
|
+
|
3
|
+
class TestWorkingCopyValidate < Piston::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@wcdir = mkpath("tmp/wc")
|
7
|
+
@wc = Piston::WorkingCopy.new(@wcdir)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_exists_when_the_directory_exists
|
11
|
+
assert @wc.exist?, "WorkingCopy should have existed, since the directory exists"
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_does_not_exist_when_directory_not_present
|
15
|
+
@wcdir.rmtree
|
16
|
+
deny @wc.exist?, "WorkingCopy should NOT have existed, since the directory does not exist"
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_does_not_exist_when_directory_is_a_file
|
20
|
+
@wcdir.rmtree
|
21
|
+
touch(@wcdir)
|
22
|
+
deny @wc.exist?, "WorkingCopy should NOT have existed, since the directory is a file"
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_is_pistonized_if_exist_and_has_piston_dot_yaml_file
|
26
|
+
@wc.stubs(:exist?).returns(true)
|
27
|
+
touch(@wcdir + ".piston.yml")
|
28
|
+
assert @wc.pistonized?, "WorkingCopy should be Pistonized, since the .piston.yml file exists"
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_is_NOT_pistonized_if_no_piston_dot_yaml_file
|
32
|
+
@wc.stubs(:exist?).returns(true)
|
33
|
+
deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since the .piston.yml does not file exists"
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_is_NOT_pistonized_if_exist_returns_false
|
37
|
+
@wc.stubs(:exist?).returns(false)
|
38
|
+
deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since #exist? returned false"
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_is_NOT_pistonized_if_piston_dot_yaml_is_a_directory
|
42
|
+
@wc.stubs(:exist?).returns(true)
|
43
|
+
(@wcdir + ".piston.yml").mkdir
|
44
|
+
deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since .piston.yml is a directory"
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_validate_bang_returns_self_when_ok
|
48
|
+
@wc.stubs(:pistonized?).returns(true)
|
49
|
+
assert_equal @wc, @wc.validate!
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_validate_bang_raises_not_working_copy_when_not_pistonized
|
53
|
+
@wc.stubs(:pistonized?).returns(false)
|
54
|
+
assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
|
55
|
+
@wc.validate!
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
protected
|
60
|
+
def touch(path)
|
61
|
+
File.open(path, "wb") {|f| f.write ""}
|
62
|
+
end
|
63
|
+
end
|