-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest_version.py
63 lines (51 loc) · 1.95 KB
/
test_version.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
63
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 The Linux Foundation and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
##############################################################################
"""Unit tests for the version command."""
import filecmp
import os
import pytest
from lftools import cli
FIXTURE_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"fixtures",
)
@pytest.mark.datafiles(
os.path.join(FIXTURE_DIR, "version_bump"),
)
def test_version_bump(cli_runner, datafiles):
"""Test version bump command."""
os.chdir(str(datafiles))
cli_runner.invoke(cli.cli, ["version", "bump", "TestRelease"], obj={})
for _file in datafiles.listdir():
pom = str(_file) + "/pom.xml"
expected_pom = str(_file) + "/pom.xml.expected"
# noqa: B101 .
assert filecmp.cmp(pom, expected_pom)
@pytest.mark.datafiles(
os.path.join(FIXTURE_DIR, "version_release"),
)
def test_version_release(cli_runner, datafiles):
"""Test version release command."""
os.chdir(str(datafiles))
cli_runner.invoke(cli.cli, ["version", "release", "TestRelease"], obj={})
for _file in datafiles.listdir():
pom = str(_file) + "/pom.xml"
expected_pom = str(_file) + "/pom.xml.expected"
# noqa: B101 .
assert filecmp.cmp(pom, expected_pom)
@pytest.mark.datafiles(
os.path.join(FIXTURE_DIR, "version_bump", "release"),
)
def test_patch(cli_runner, datafiles):
"""Test patch command."""
os.chdir(str(datafiles))
result = cli_runner.invoke(cli.cli, ["version", "patch", "TestRelease", os.path.join(datafiles, "README")], obj={})
assert result.exit_code == 404