|
| 1 | +require File.dirname(__FILE__) + '/../test_helper' |
| 2 | + |
| 3 | +module Scm::Adapters |
| 4 | + class BzrPushTest < Scm::Test |
| 5 | + |
| 6 | + def test_hostname |
| 7 | + assert !BzrAdapter.new.hostname |
| 8 | + assert !BzrAdapter.new(:url => "http://www.ohloh.net/test").hostname |
| 9 | + assert !BzrAdapter.new(:url => "/Users/test/foo").hostname |
| 10 | + assert_equal "foo", BzrAdapter.new(:url => 'ssh://foo/bar').hostname |
| 11 | + end |
| 12 | + |
| 13 | + def test_local |
| 14 | + assert !BzrAdapter.new(:url => "foo:/bar").local? # Assuming your machine is not named "foo" :-) |
| 15 | + assert !BzrAdapter.new(:url => "http://www.ohloh.net/foo").local? |
| 16 | + assert !BzrAdapter.new(:url => "ssh://host/Users/test/src").local? |
| 17 | + assert BzrAdapter.new(:url => "src").local? |
| 18 | + assert BzrAdapter.new(:url => "/Users/test/src").local? |
| 19 | + assert BzrAdapter.new(:url => "file:///Users/test/src").local? |
| 20 | + assert BzrAdapter.new(:url => "ssh://#{Socket.gethostname}/Users/test/src").local? |
| 21 | + end |
| 22 | + |
| 23 | + def test_path |
| 24 | + assert_equal nil, BzrAdapter.new().path |
| 25 | + assert_equal nil, BzrAdapter.new(:url => "http://ohloh.net/foo").path |
| 26 | + assert_equal nil, BzrAdapter.new(:url => "https://ohloh.net/foo").path |
| 27 | + assert_equal "/Users/test/foo", BzrAdapter.new(:url => "file:///Users/test/foo").path |
| 28 | + assert_equal "/Users/test/foo", BzrAdapter.new(:url => "ssh://localhost/Users/test/foo").path |
| 29 | + assert_equal "/Users/test/foo", BzrAdapter.new(:url => "/Users/test/foo").path |
| 30 | + end |
| 31 | + |
| 32 | + def test_bzr_path |
| 33 | + assert_equal nil, BzrAdapter.new().bzr_path |
| 34 | + assert_equal "/Users/test/src/.bzr", BzrAdapter.new(:url => "/Users/test/src").bzr_path |
| 35 | + end |
| 36 | + |
| 37 | + def test_push |
| 38 | + with_bzr_repository('bzr') do |src| |
| 39 | + Scm::ScratchDir.new do |dest_dir| |
| 40 | + |
| 41 | + dest = BzrAdapter.new(:url => dest_dir).normalize |
| 42 | + assert !dest.exist? |
| 43 | + |
| 44 | + src.push(dest) |
| 45 | + assert dest.exist? |
| 46 | + assert_equal src.log, dest.log |
| 47 | + |
| 48 | + # Commit some new code on the original and pull again |
| 49 | + src.run "cd '#{src.url}' && touch foo && bzr add foo && bzr whoami 'test <[email protected]>' && bzr commit -m test" |
| 50 | + assert_equal "test\n", src.commits.last.message |
| 51 | + assert_equal "test", src.commits.last.committer_name |
| 52 | + assert_equal "[email protected]", src.commits.last.committer_email |
| 53 | + |
| 54 | + src.push(dest) |
| 55 | + assert_equal src.log, dest.log |
| 56 | + end |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + end |
| 61 | +end |
0 commit comments