Skip to content

Commit 07225a8

Browse files
committed
test: add integration test for search local repo
Part of #TNTP-1094
1 parent 5bb3162 commit 07225a8

15 files changed

+73
-10
lines changed

cli/search/search_local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func searchVersionsLocalSDK(program, localDir string) (
5454
case ProgramEe:
5555
prefix = "tarantool-enterprise-sdk-"
5656
case ProgramTcm:
57-
prefix = "tcm-sdk-" // FIXME: it needs to adjust for TCM.
57+
prefix = "tcm-"
5858
default:
5959
// Should not happen if called correctly, but good practice to handle.
6060
return nil, fmt.Errorf("local SDK file search not supported for %s", program)

test/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
import signal
55
import subprocess
6+
from pathlib import Path
67

78
import etcd_helper
89
import psutil
@@ -38,7 +39,7 @@ def cli_config_dir():
3839

3940

4041
@pytest.fixture(scope="session")
41-
def tt_cmd(tmp_path_factory):
42+
def tt_cmd(tmp_path_factory) -> Path:
4243
tt_build_dir = tmp_path_factory.mktemp("tt_build")
4344
tt_base_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
4445
tt_path = tt_build_dir / "tt"

test/integration/search/test_search.py

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import re
3+
from pathlib import Path
34

45
import pytest
56

@@ -28,23 +29,69 @@ def test_version_cmd(tt_cmd, tmp_path):
2829
assert re.search(r"Search for available versions for the program", output)
2930

3031

32+
@pytest.mark.parametrize(
33+
"program,versions",
34+
[
35+
(
36+
"tarantool-ee",
37+
[
38+
"gc64-3.2.0-0-r40",
39+
"gc64-3.3.1-0-r55",
40+
"gc64-3.3.2-0-r58",
41+
"gc64-3.3.2-0-r59",
42+
],
43+
),
44+
(
45+
"tcm",
46+
[
47+
"1.2.0-4-g59faf8b74",
48+
"1.2.0-6-g0a82e719",
49+
"1.2.0-11-g2d0a0f495",
50+
"1.2.1-0-gc2199e13e",
51+
"1.2.3-0-geae7e7d49",
52+
"1.3.0-0-g3857712a",
53+
"1.3.1-0-g074b5ffa",
54+
],
55+
),
56+
],
57+
)
58+
def test_local_repo_sdk(
59+
tt_cmd: Path, tmp_path: Path, program: str, versions: list[str]
60+
) -> None:
61+
configPath = Path(__file__).parent / "testdata" / config_name
62+
cmd = [tt_cmd, "--cfg", configPath, "search", "--local-repo", program]
63+
# Run `tt`` in temporary directory, to ensure that it will find `distfiles` from the config.
64+
rc, gotVersions = run_command_and_get_output(cmd, cwd=tmp_path, stderr=None)
65+
assert rc == 0
66+
expected = "\n".join(versions)
67+
assert (
68+
expected == gotVersions.strip()
69+
), f"Expected versions: {expected}, got: {gotVersions}"
70+
71+
3172
@pytest.mark.slow
3273
def test_version_cmd_local(tt_cmd, tmp_path):
3374
configPath = os.path.join(tmp_path, config_name)
3475
# Create test config
3576
distfilesPath = os.path.join(tmp_path, "distfiles")
3677
os.mkdir(distfilesPath)
37-
with open(configPath, 'w') as f:
38-
f.write('tt:\n app:\n')
78+
with open(configPath, "w") as f:
79+
f.write("tt:\n app:\n")
3980
# Download tt and tarantool repos into distfiles directory.
40-
cmd_download_tarantool = ["git", "clone",
41-
"https://github.com/tarantool/tarantool.git",
42-
os.path.join(distfilesPath, "tarantool")]
81+
cmd_download_tarantool = [
82+
"git",
83+
"clone",
84+
"https://github.com/tarantool/tarantool.git",
85+
os.path.join(distfilesPath, "tarantool"),
86+
]
4387
rc, _ = run_command_and_get_output(cmd_download_tarantool, cwd=tmp_path)
4488
assert rc == 0
45-
cmd_download_tt = ["git", "clone",
46-
"https://github.com/tarantool/tt",
47-
os.path.join(distfilesPath, "tt")]
89+
cmd_download_tt = [
90+
"git",
91+
"clone",
92+
"https://github.com/tarantool/tt",
93+
os.path.join(distfilesPath, "tt"),
94+
]
4895
rc, _ = run_command_and_get_output(cmd_download_tt, cwd=tmp_path)
4996
assert rc == 0
5097
cmd = [tt_cmd, "search", "--local-repo", "tarantool"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
repo:
2+
# The directory where the installation files are stored has been changed
3+
# to not match the default `distfiles` of the config.
4+
distfiles: distfiles.test

0 commit comments

Comments
 (0)