File: push_test.rb

package info (click to toggle)
ruby-rugged 1.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,752 kB
  • sloc: ansic: 8,722; ruby: 7,473; sh: 99; makefile: 5
file content (58 lines) | stat: -rw-r--r-- 2,554 bytes parent folder | download
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
49
50
51
52
53
54
55
56
57
58
require 'test_helper'

class OnlineGitPushTest < Rugged::OnlineTestCase
  def setup
    skip unless git_creds?
    @repo = FixtureRepo.from_libgit2("push_src")
    @remote = @repo.remotes.create("test", ENV['GITTEST_REMOTE_GIT_URL'])
    @target_repo = Rugged::Repository.new(ENV['GITTEST_REMOTE_REPO_PATH'])
  end

  def test_push_branches
    skip unless git_creds?

    @remote.push([
                   "refs/heads/b1:refs/heads/b1",
                   "refs/heads/b2:refs/heads/b2",
                   "refs/heads/b3:refs/heads/b3",
                   "refs/heads/b4:refs/heads/b4",
                   "refs/heads/b5:refs/heads/b5"
                 ])

    assert_equal @repo.references["refs/heads/b1"].target_id, @target_repo.references["refs/heads/b1"].target_id
    assert_equal @repo.references["refs/heads/b2"].target_id, @target_repo.references["refs/heads/b2"].target_id
    assert_equal @repo.references["refs/heads/b3"].target_id, @target_repo.references["refs/heads/b3"].target_id
    assert_equal @repo.references["refs/heads/b4"].target_id, @target_repo.references["refs/heads/b4"].target_id
    assert_equal @repo.references["refs/heads/b5"].target_id, @target_repo.references["refs/heads/b5"].target_id
  end
end

class OnlineSshPushTest < Rugged::OnlineTestCase
  def setup
    skip unless Rugged.features.include?(:ssh) && ssh_creds?

    @repo = FixtureRepo.from_libgit2("push_src")
    @remote = @repo.remotes.create("test", ENV['GITTEST_REMOTE_SSH_URL'])
    @target_repo = Rugged::Repository.new(ENV['GITTEST_REMOTE_REPO_PATH'])
  end

  def test_push_branches
    skip unless ssh_creds?

    @remote.push([
                   "refs/heads/b1:refs/heads/b1",
                   "refs/heads/b2:refs/heads/b2",
                   "refs/heads/b3:refs/heads/b3",
                   "refs/heads/b4:refs/heads/b4",
                   "refs/heads/b5:refs/heads/b5"
                 ], **{
                   credentials: ssh_key_credential
                 })

    assert_equal @repo.references["refs/heads/b1"].target_id, @target_repo.references["refs/heads/b1"].target_id
    assert_equal @repo.references["refs/heads/b2"].target_id, @target_repo.references["refs/heads/b2"].target_id
    assert_equal @repo.references["refs/heads/b3"].target_id, @target_repo.references["refs/heads/b3"].target_id
    assert_equal @repo.references["refs/heads/b4"].target_id, @target_repo.references["refs/heads/b4"].target_id
    assert_equal @repo.references["refs/heads/b5"].target_id, @target_repo.references["refs/heads/b5"].target_id
  end
end