Skip to content

Commit

Permalink
Fix git SCM module unit tests (closes #11221)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@8938 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Feb 28, 2008
1 parent 23a6f61 commit 645fff0
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions test/deploy/scm/git_test.rb
Expand Up @@ -15,14 +15,16 @@ def @config.exists?(name); key?(name); end

def test_head
assert_equal "HEAD", @source.head

# With :branch
@config[:branch] = "master"
assert_equal "master", @source.head
end

def origin
asser_equal "origin", @source.origin
@config[:remote] = "git"
assert_equal "git", @source.origin
def test_origin
assert_equal "origin", @source.origin
@config[:remote] = "username"
assert_equal "username", @source.origin
end

def test_checkout
Expand All @@ -31,9 +33,10 @@ def test_checkout
rev = 'c2d9e79'
assert_equal "git clone git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)

# With branch
@config[:branch] = "origin/foo"
assert_equal "git clone git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)
# With :scm_command
git = "/opt/local/bin/git"
@config[:scm_command] = git
assert_equal "#{git} clone git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -b deploy #{rev}", @source.checkout(rev, dest)
end

def test_diff
Expand Down Expand Up @@ -61,11 +64,6 @@ def test_sync
rev = 'c2d9e79'
assert_equal "cd #{dest} && git fetch origin && git reset --hard #{rev}", @source.sync(rev, dest)

# With branch
@config[:branch] = "foo"
rev = '92d9e79' # simulate rev change
assert_equal "cd #{dest} && git fetch origin && git reset --hard #{rev}", @source.sync(rev, dest)

# With :scm_command
git = "/opt/local/bin/git"
@config[:scm_command] = git
Expand All @@ -90,11 +88,6 @@ def test_shallow_clone
dest = "/var/www"
rev = 'c2d9e79'
assert_equal "git clone --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)

# With branch
@config[:branch] = "origin/foo"
rev = '92d9e79' # simulate rev change
assert_equal "git clone --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)
end

def test_remote_clone
Expand All @@ -103,10 +96,6 @@ def test_remote_clone
dest = "/var/www"
rev = 'c2d9e79'
assert_equal "git clone -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)

# With branch
@config[:branch] = "foo"
assert_equal "git clone -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)
end

# Tests from base_test.rb, makin' sure we didn't break anything up there!
Expand Down

0 comments on commit 645fff0

Please sign in to comment.