Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace bin in hard tests #1265

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/mockdata/mock_build_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from Testing import get_tested_mock_package

BUILDDATE = get_tested_mock_package(
files={
'/bin/with-date': {'content': """Jan 1 2019"""},
'/bin/with-datetime': {'content': """Jan 1 2019 12:15:11"""}
}
)

BUILDDATE2 = get_tested_mock_package(
files={
'/bin/script1',
'/bin/script2'
}
)
15 changes: 8 additions & 7 deletions test/test_build_date.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import re

from mockdata.mock_build_date import BUILDDATE, BUILDDATE2
import pytest
from rpmlint.checks.BuildRootAndDateCheck import BuildRootAndDateCheck
from rpmlint.filter import Filter

from Testing import CONFIG, get_tested_package
from Testing import CONFIG


@pytest.fixture(scope='function', autouse=True)
Expand All @@ -15,21 +16,21 @@ def builddatecheck():
return output, test


@pytest.mark.parametrize('package', ['binary/builddate'])
def test_build_date_time(tmp_path, package, builddatecheck):
@pytest.mark.parametrize('package', [BUILDDATE])
def test_build_date_time(package, builddatecheck):
output, test = builddatecheck
test.istoday = re.compile('Jan 1 2019')
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)
assert 'E: file-contains-date-and-time /bin/with-datetime' in out
assert 'E: file-contains-current-date /bin/with-date' in out


@pytest.mark.parametrize('package', ['binary/bashisms'])
def test_build_date_time_correct(tmp_path, package, builddatecheck):
@pytest.mark.parametrize('package', [BUILDDATE2])
def test_build_date_time_correct(package, builddatecheck):
output, test = builddatecheck
test.istoday = re.compile('Jan 1 2019')
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)
assert 'E: file-contains-date-and-time' not in out
assert 'E: file-contains-current-date' not in out
Loading