|
25 | 25 |
|
26 | 26 | """Tests for Remote objects."""
|
27 | 27 |
|
| 28 | +from unittest.mock import patch |
28 | 29 | import sys
|
29 | 30 |
|
30 | 31 | import pytest
|
31 | 32 |
|
32 | 33 | import pygit2
|
33 | 34 | from pygit2 import Oid
|
| 35 | +from pygit2.ffi import ffi |
34 | 36 | from . import utils
|
35 | 37 |
|
36 | 38 |
|
@@ -356,3 +358,25 @@ def test_push_non_fast_forward_commits_to_remote_fails(origin, clone, remote):
|
356 | 358 |
|
357 | 359 | with pytest.raises(pygit2.GitError):
|
358 | 360 | remote.push(['refs/heads/master'])
|
| 361 | + |
| 362 | + |
| 363 | +@patch.object(pygit2.callbacks, 'RemoteCallbacks') |
| 364 | +def test_push_options(mock_callbacks, origin, clone, remote): |
| 365 | + remote.push(['refs/heads/master']) |
| 366 | + remote_push_options = mock_callbacks.return_value.push_options.remote_push_options |
| 367 | + assert remote_push_options.count == 0 |
| 368 | + |
| 369 | + remote.push(['refs/heads/master'], push_options=[]) |
| 370 | + remote_push_options = mock_callbacks.return_value.push_options.remote_push_options |
| 371 | + assert remote_push_options.count == 0 |
| 372 | + |
| 373 | + remote.push(['refs/heads/master'], push_options=['foo']) |
| 374 | + remote_push_options = mock_callbacks.return_value.push_options.remote_push_options |
| 375 | + assert remote_push_options.count == 1 |
| 376 | + assert ffi.string(remote_push_options.strings[0]) == b'foo' |
| 377 | + |
| 378 | + remote.push(['refs/heads/master'], push_options=['Option A', 'Option B']) |
| 379 | + remote_push_options = mock_callbacks.return_value.push_options.remote_push_options |
| 380 | + assert remote_push_options.count == 2 |
| 381 | + assert ffi.string(remote_push_options.strings[0]) == b'Option A' |
| 382 | + assert ffi.string(remote_push_options.strings[1]) == b'Option B' |
0 commit comments