| 1 |
""" |
| 2 |
Tests for bad arguments to publish |
| 3 |
""" |
| 4 |
|
| 5 |
from drivers.alr import run_alr |
| 6 |
from drivers.asserts import assert_match |
| 7 |
|
| 8 |
# Check that a local zip is rejected (as it must be remote) |
| 9 |
p = run_alr("publish", "file:/fake.zip", complain_on_error=False) |
| 10 |
assert_match(".*The origin must be a definitive remote location.*", p.out) |
| 11 |
|
| 12 |
# Bad combo, explicit file + commit |
| 13 |
p = run_alr("publish", "file:/fake.zip", "deadbeef", complain_on_error=False) |
| 14 |
assert_match(".*Expected a VCS origin but got.*", p.out) |
| 15 |
|
| 16 |
# Bad combo, implicit file + commit |
| 17 |
p = run_alr("publish", "fake.zip", "deadbeef", complain_on_error=False) |
| 18 |
assert_match(".*unknown VCS URL.*", p.out) |
| 19 |
|
| 20 |
# Missing commit for git remotes |
| 21 |
p = run_alr("publish", "git+http://github.com/repo", |
| 22 |
complain_on_error=False) |
| 23 |
assert_match(".*commit id is mandatory for a VCS origin.*", p.out) |
| 24 |
|
| 25 |
# Detect github case and give more precise error. This serves also to check |
| 26 |
# that github remotes without leading git+ or trailing .git are accepted. |
| 27 |
p = run_alr("publish", "https://github.com/missingext", |
| 28 |
complain_on_error=False) |
| 29 |
assert_match(".*commit id is mandatory for a VCS origin.*", p.out) |
| 30 |
|
| 31 |
# Bad commit length |
| 32 |
p = run_alr("publish", "git+http://github.com/repo", "deadbeef", |
| 33 |
complain_on_error=False) |
| 34 |
assert_match(".*invalid git commit id, 40 digits hexadecimal expected.*", |
| 35 |
p.out) |
| 36 |
|
| 37 |
# VCS without transport or extension |
| 38 |
p = run_alr("publish", "http://somehost.com/badrepo", "deadbeef", |
| 39 |
complain_on_error=False) |
| 40 |
assert_match(".*ambiguous VCS URL.*", p.out) |
| 41 |
|
| 42 |
print('SUCCESS') |