Skip to content

Commit f08c626

Browse files
committed
add cli_download_and_extract method test
Signed-off-by: MoonJeWoong <[email protected]>
1 parent 751a89d commit f08c626

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

tests/test_download.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,33 @@
66

77
from fosslight_util.download import cli_download_and_extract
88
from tests import constants
9+
from git import Repo
910

1011

1112
def test_download_from_github():
13+
# given
14+
git_url = "https://github.com/LGE-OSS/example"
15+
target_dir = os.path.join(constants.TEST_RESULT_DIR, "download/example")
16+
log_dir = "test_result/download_log/example"
17+
1218
# when
19+
success, _, _, _ = cli_download_and_extract(git_url, target_dir, log_dir)
20+
21+
# then
22+
assert success is True
23+
assert len(os.listdir(target_dir)) > 0
24+
25+
26+
@pytest.mark.parametrize("git_url",
27+
["git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;protocol=git;branch=ci-test",
28+
"git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;protocol=git;tag=v32"])
29+
def test_download_from_github_with_branch_or_tag(git_url):
30+
# given
1331
target_dir = os.path.join(constants.TEST_RESULT_DIR, "download/example")
14-
success, _, _, _ = cli_download_and_extract("https://github.com/LGE-OSS/example",
15-
target_dir,
16-
"test_result/download_log/example")
32+
log_dir = "test_result/download_log/example"
33+
34+
# when
35+
success, _, _, _ = cli_download_and_extract(git_url, target_dir, log_dir)
1736

1837
# then
1938
assert success is True

0 commit comments

Comments
 (0)