Skip to content

Commit 40baeaa

Browse files
Automatically reset the remote repo for online test cases.
1 parent 8b798a4 commit 40baeaa

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

test/online/fetch_test.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ def setup
77

88
if git_creds?
99
def test_fetch_over_git
10-
reset_remote_repo
11-
1210
@repo.remotes.create("origin", ENV['GITTEST_REMOTE_GIT_URL'])
1311

1412
@repo.fetch("origin")
@@ -34,8 +32,6 @@ def test_fetch_over_https
3432

3533
if Rugged.features.include?(:ssh) && ssh_creds?
3634
def test_fetch_over_ssh_with_credentials
37-
reset_remote_repo
38-
3935
@repo.remotes.create("origin", ENV['GITTEST_REMOTE_SSH_URL'])
4036

4137
@repo.fetch("origin", {
@@ -44,8 +40,6 @@ def test_fetch_over_ssh_with_credentials
4440
end
4541

4642
def test_fetch_over_ssh_with_credentials_from_agent
47-
reset_remote_repo
48-
4943
@repo.remotes.create("origin", ENV['GITTEST_REMOTE_SSH_URL'])
5044

5145
@repo.fetch("origin", {
@@ -54,8 +48,6 @@ def test_fetch_over_ssh_with_credentials_from_agent
5448
end
5549

5650
def test_fetch_over_ssh_with_credentials_callback
57-
reset_remote_repo
58-
5951
@repo.remotes.create("origin", ENV['GITTEST_REMOTE_SSH_URL'])
6052

6153
@repo.fetch("origin", {

test/online/ls_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ def test_ls_over_https
2525

2626
if git_creds?
2727
def test_ls_over_git
28-
reset_remote_repo
29-
3028
remote = @repo.remotes.create("origin", ENV['GITTEST_REMOTE_GIT_URL'])
3129
remote.push(["refs/heads/b1:refs/heads/b1"])
3230

@@ -38,8 +36,6 @@ def test_ls_over_git
3836

3937
if Rugged.features.include?(:ssh) && ssh_creds?
4038
def test_ls_over_ssh_with_credentials
41-
reset_remote_repo
42-
4339
remote = @repo.remotes.create("origin", ENV['GITTEST_REMOTE_SSH_URL'])
4440
remote.push(["refs/heads/b1:refs/heads/b1"], credentials: ssh_key_credential)
4541

test/test_helper.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,15 @@ def self.with_cleanup(repo, path)
100100
end
101101

102102
class OnlineTestCase < TestCase
103-
def reset_remote_repo
104-
remote_repo = Rugged::Repository.new(ENV['GITTEST_REMOTE_REPO_PATH'])
105-
remote_repo.references.each do |ref|
106-
remote_repo.references.delete(ref)
103+
if ENV['GITTEST_REMOTE_REPO_PATH']
104+
def before_setup
105+
remote_repo = Rugged::Repository.new(ENV['GITTEST_REMOTE_REPO_PATH'])
106+
remote_repo.references.each do |ref|
107+
remote_repo.references.delete(ref)
108+
end
109+
110+
super
107111
end
108-
remote_repo.close
109112
end
110113

111114
def self.ssh_creds?

0 commit comments

Comments
 (0)