Fix tests to work in CI

Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
Václav Valíček 2022-07-28 21:32:55 +02:00
parent b1b0554e60
commit a22b74fba9
Signed by: valicek
GPG Key ID: FF05BDCA0C73BB31

View File

@ -1,5 +1,6 @@
import git import git
import pytest import pytest
from repo_cloner.lib.checksum import gen_repo_hashed_name
import repo_cloner.lib.dir_not_found_error import repo_cloner.lib.dir_not_found_error
from cloner_test_fixtures import * from cloner_test_fixtures import *
from repo_cloner.lib.cloner import Cloner from repo_cloner.lib.cloner import Cloner
@ -127,9 +128,10 @@ def test_repo_path_by_url(cloner_dir_struct: Path, path_repo_base: Path):
def test__main_repo_path(cloner_dir_struct: Path, path_repo_base: Path): def test__main_repo_path(cloner_dir_struct: Path, path_repo_base: Path):
ds = MockDirStruct(cloner_dir_struct) ds = MockDirStruct(cloner_dir_struct)
ds.config.cloner_repo_url = path_repo_base.as_uri() ds.config.cloner_repo_url = path_repo_base.as_uri()
hashed = gen_repo_hashed_name(path_repo_base.as_uri())
c = Cloner(ds) c = Cloner(ds)
x = c._Cloner__main_repo_path x = c._Cloner__main_repo_path
assert x == ds.repos_dir.joinpath("_support_data_test-repo-base_402961715.git").as_posix() assert x == ds.repos_dir.joinpath(hashed).as_posix()
def test_sync(cloner_dir_struct, tmp_path, monkeypatch): def test_sync(cloner_dir_struct, tmp_path, monkeypatch):
@ -222,7 +224,8 @@ def test_open_uninitialized(cloner_dir_with_config, path_repo_base):
def test_open_initialized(cloner_dir_with_config, path_repo_base, caplog): def test_open_initialized(cloner_dir_with_config, path_repo_base, caplog):
mock = MockDirStruct(cloner_dir_with_config) mock = MockDirStruct(cloner_dir_with_config)
path = cloner_dir_with_config.joinpath("repos", "_support_data_test-repo-base_402961715.git").as_posix() hashed = gen_repo_hashed_name(path_repo_base.as_uri())
path = cloner_dir_with_config.joinpath("repos", hashed).as_posix()
mock.config.cloner_repo_url = path_repo_base.as_uri() mock.config.cloner_repo_url = path_repo_base.as_uri()
r = git.Repo().clone_from(path_repo_base.as_uri(), path, bare = True) r = git.Repo().clone_from(path_repo_base.as_uri(), path, bare = True)
commit = r.head.commit.hexsha commit = r.head.commit.hexsha
@ -242,9 +245,10 @@ def test_clone_from_url(tmp_path, path_repo_base):
def test_clone_from_url_initialized(tmp_path, path_repo_base, caplog): def test_clone_from_url_initialized(tmp_path, path_repo_base, caplog):
mock = MockDirStruct(tmp_path) mock = MockDirStruct(tmp_path)
path = tmp_path.joinpath("repos", "_support_data_test-repo-base_402961715.git").as_posix() hashed = gen_repo_hashed_name(path_repo_base.as_uri())
path = tmp_path.joinpath("repos", hashed).as_posix()
mock.config.cloner_repo_url = path_repo_base.as_uri() mock.config.cloner_repo_url = path_repo_base.as_uri()
r = git.Repo().init(path) git.Repo().init(path)
c = Cloner(mock) c = Cloner(mock)
assert not c.clone_from_url(path_repo_base.as_uri()) assert not c.clone_from_url(path_repo_base.as_uri())
assert caplog.records[0].levelname == "CRITICAL" assert caplog.records[0].levelname == "CRITICAL"