Skip to content

Commit 1e8fb99

Browse files
committed
test: fix unit tests
Signed-off-by: behnazh-w <[email protected]>
1 parent b45488c commit 1e8fb99

File tree

4 files changed

+7
-35
lines changed

4 files changed

+7
-35
lines changed

tests/policy_engine/test_policy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def test_dump_prelude(database_setup) -> None: # type: ignore # pylint: disable
3333
def test_eval_policy(database_setup) -> None: # type: ignore # pylint: disable=unused-argument,redefined-outer-name
3434
"""Test loading the policy from file."""
3535
res = run_souffle(os.path.join(POLICY_FILE, DATABASE_FILE), POLICY_FILE)
36-
res.pop("repo_satisfies_policy")
37-
res.pop("repo_violates_policy")
36+
res.pop("component_satisfies_policy")
37+
res.pop("component_violates_policy")
3838
assert res == {
3939
"passed_policies": [["trusted_builder"]],
4040
"failed_policies": [["aggregate_l4"], ["aggregate_l2"]],

tests/slsa_analyzer/mock_git_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2022, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
"""
@@ -101,9 +101,8 @@ def prepare_repo_for_testing(
101101
branch_name="master",
102102
commit_sha="",
103103
commit_date="",
104-
files=git_repo.files,
105-
macaron_path=str(macaron_path),
106-
output_dir=str(output_dir),
104+
files=git_repo.files(),
105+
fs_path=str(repo_path),
107106
),
108107
)
109108

tests/slsa_analyzer/provenance/expectations/cue/test_cue_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_make_expectation(expectation_path: str) -> None:
3535
@pytest.mark.parametrize(
3636
("expectation_path", "expected"),
3737
[
38-
(os.path.join(EXPEC_RESOURCE_PATH, "valid_expectations", "urllib3_PASS.cue"), "urllib3/urllib3"),
38+
(os.path.join(EXPEC_RESOURCE_PATH, "valid_expectations", "urllib3_PASS.cue"), "pkg:github.com/urllib3/urllib3"),
3939
(os.path.join(EXPEC_RESOURCE_PATH, "valid_expectations", "urllib3_FAIL.cue"), ""),
4040
],
4141
)

tests/slsa_analyzer/test_git_url.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,6 @@ def test_get_repo_name_from_url(
6161
valid_git_urls: list[str], invalid_git_urls: list[str], repo_name: str, repo_full_name: str, repo_complete_name: str
6262
) -> None:
6363
"""Test the extract repo name, full name, and complete name from url method."""
64-
valid_git_urls = [
65-
f"[email protected]:owner/{repo_name}.git",
66-
f"[email protected]:owner/{repo_name}.git",
67-
f"https://gitlab.com/owner/{repo_name}",
68-
f"https://github.com/owner/{repo_name}.git",
69-
f"https://github.com/owner/{repo_name}",
70-
f"git+https://github.com/owner/{repo_name}",
71-
f"git+ssh://[email protected]/owner/{repo_name}.git",
72-
f"git+ssh://[email protected]/owner/{repo_name}",
73-
f"git+ssh://[email protected]:owner/{repo_name}.git",
74-
f"git+ssh://[email protected]:8080/owner/{repo_name}",
75-
f"ssh://[email protected]/owner/{repo_name}.git",
76-
f"ssh://[email protected]/owner/{repo_name}",
77-
f"ssh://[email protected]:owner/{repo_name}.git",
78-
f"ssh://[email protected]:8080/owner/{repo_name}",
79-
f"scm:ssh://[email protected]:8080/owner/{repo_name}",
80-
]
81-
invalid_git_urls = [
82-
"",
83-
f"{repo_name}.git",
84-
f"{repo_name}.git/",
85-
"ssh://[email protected]:8080/invalid/",
86-
"https://gitlab.com/invalid.git",
87-
"ssh://[email protected]:8080/",
88-
89-
]
90-
9164
# Test get repo name.
9265
assert all(git_url.get_repo_name_from_url(url) == repo_name for url in valid_git_urls)
9366
assert not any(git_url.get_repo_name_from_url(url) for url in invalid_git_urls)
@@ -98,7 +71,7 @@ def test_get_repo_name_from_url(
9871

9972
# Test get repo complete name.
10073
assert all(git_url.get_repo_complete_name_from_url(url) == repo_complete_name for url in valid_git_urls)
101-
assert not all(git_url.get_repo_complete_name_from_url(url) for url in invalid_git_urls)
74+
assert not any(git_url.get_repo_complete_name_from_url(url) for url in invalid_git_urls)
10275

10376

10477
def test_clone_remote_repo() -> None:

0 commit comments

Comments
 (0)