-
Notifications
You must be signed in to change notification settings - Fork 134
/
test_autoversion.py
executable file
·62 lines (50 loc) · 2.41 KB
/
test_autoversion.py
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
59
60
61
62
#!/usr/bin/python3
import re
import autoversion
def test_version_regex():
regex = autoversion.VERSION_MATCHER
# Should match.
assert re.search(regex, "1.2.3") is not None
assert re.search(regex, "1.2.3b2") is not None
assert re.search(regex, "1.2.3-build123") is not None
assert re.search(regex, "1.2.3-build123").group(0) == "1.2.3-build123"
assert re.search(regex, "release_2_1.2.3") is not None
assert re.search(regex, "release_2_1.2.3.mender") is not None
assert re.search(regex, "release_2_1.2.3_mender") is not None
assert re.search(regex, "release.2_1.2.3_mender") is not None
assert re.search(regex, "release.2_1.2.3.mender") is not None
assert re.search(regex, "release.2_1.2.3_2") is not None
assert re.search(regex, "release.2_master_2") is not None
assert re.search(regex, "morty") is not None
# Special case: mender-X.Y.Z
assert re.search(regex, "mender-1.2.3") is not None
assert re.search(regex, "mender-1.2.3").group(0) == "mender-1.2.3"
assert re.search(regex, "something-mender-1.2.3-else") is not None
assert re.search(regex, "something-mender-1.2.3-else").group(0) == "mender-1.2.3"
assert re.search(regex, "1.2.3-mender") is not None
assert re.search(regex, "1.2.3-mender").group(0) == "1.2.3"
assert re.search(regex, "mender.1.2.3") is not None
assert re.search(regex, "mender.1.2.3").group(0) == "1.2.3"
# Should not match.
assert re.search(regex, "1.2.3.4") is None
assert re.search(regex, "11.2.3.4") is None
assert re.search(regex, "1.2.3.14") is None
assert re.search(regex, "2.1.2.3.4") is None
assert re.search(regex, "22.1.2.3.4") is None
assert re.search(regex, "22.11.2.3.4") is None
assert re.search(regex, "127.0.0.1") is None
assert re.search(regex, "mortyxxx") is None
def test_minor_versions_regex():
regex = autoversion.MINOR_VERSIONS_MATCHER
# Should match.
assert re.search(regex, "1.2") is not None
assert re.search(regex, "1.2, 1.3, 1.4").group(0) == "1.2, 1.3, 1.4"
assert re.search(regex, "something 1.2 else") is not None
assert re.search(regex, "even 1.2.") is not None
# Should not match.
assert re.search(regex, "1.2.3") is None
assert re.search(regex, "11.2.3.4") is None
assert re.search(regex, "1.2.3.14, 12.3.1, 123.5.5") is None
assert re.search(regex, "a.1, 2.c, b.4") is None
test_version_regex()
test_minor_versions_regex()