mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: expand on update.py tests and show on Gitlab UI
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
parent
137ed04d34
commit
ef2baad7b3
4 changed files with 80 additions and 4 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -44,3 +44,8 @@ doc/rpc.html
|
|||
|
||||
# Ignore .python-version file from Pyenv
|
||||
.python-version
|
||||
|
||||
# Ignore coverage report
|
||||
coverage.xml
|
||||
# Ignore pytest report
|
||||
report.xml
|
||||
|
|
|
@ -51,11 +51,12 @@ test:
|
|||
# Run sharness.
|
||||
- make -C test sh
|
||||
# Run pytest.
|
||||
- pytest
|
||||
- pytest --junitxml="pytest-report.xml"
|
||||
- make -C test coverage # Produce coverage reports.
|
||||
coverage: '/TOTAL.*\s+(\d+\%)/'
|
||||
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
|
||||
artifacts:
|
||||
reports:
|
||||
junit: pytest-report.xml
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: coverage.xml
|
||||
|
|
|
@ -25,7 +25,7 @@ rm -rf $PROMETHEUS_MULTIPROC_DIR
|
|||
mkdir -p $PROMETHEUS_MULTIPROC_DIR
|
||||
|
||||
# Run pytest with optional targets in front of it.
|
||||
pytest
|
||||
pytest --junitxml="/data/pytest-report.xml"
|
||||
|
||||
# By default, report coverage and move it into cache.
|
||||
if [ $COVERAGE -eq 1 ]; then
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import json
|
||||
|
||||
import pytest
|
||||
from srcinfo import parse
|
||||
|
||||
from aurweb.git.update import extract_arch_fields
|
||||
from aurweb.git.update import extract_arch_fields, parse_dep, size_humanize
|
||||
|
||||
SRCINFO = """
|
||||
pkgbase = ponies
|
||||
|
@ -131,3 +132,72 @@ def test_git_update_extract_arch_fields():
|
|||
assert sources[0]["value"] == "ponies.service"
|
||||
|
||||
# add more...
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"size, expected",
|
||||
[
|
||||
(1024, "1024B"),
|
||||
(1024.5, "1024.50B"),
|
||||
(256000, "250.00KiB"),
|
||||
(25600000, "24.41MiB"),
|
||||
(2560000000, "2.38GiB"),
|
||||
(2560000000000, "2.33TiB"),
|
||||
(2560000000000000, "2.27PiB"),
|
||||
(2560000000000000000, "2.22EiB"),
|
||||
(2560000000000000000000, "2.17ZiB"),
|
||||
(2560000000000000000000000, "2.12YiB"),
|
||||
],
|
||||
)
|
||||
def test_size_humanize(size: any, expected: str):
|
||||
assert size_humanize(size) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"depstring, exp_depname, exp_depdesc, exp_depcond",
|
||||
[
|
||||
(
|
||||
"my-little-pony: optional kids support",
|
||||
"my-little-pony",
|
||||
"optional kids support",
|
||||
"",
|
||||
),
|
||||
(
|
||||
"my-little-pony>7",
|
||||
"my-little-pony",
|
||||
"",
|
||||
">7",
|
||||
),
|
||||
(
|
||||
"my-little-pony=7",
|
||||
"my-little-pony",
|
||||
"",
|
||||
"=7",
|
||||
),
|
||||
(
|
||||
"my-little-pony<7",
|
||||
"my-little-pony",
|
||||
"",
|
||||
"<7",
|
||||
),
|
||||
(
|
||||
"my-little-pony=<7",
|
||||
"my-little-pony",
|
||||
"",
|
||||
"=<7",
|
||||
),
|
||||
(
|
||||
"my-little-pony>=7.1: optional kids support",
|
||||
"my-little-pony",
|
||||
"optional kids support",
|
||||
">=7.1",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_parse_dep(
|
||||
depstring: str, exp_depname: str, exp_depdesc: str, exp_depcond: str
|
||||
):
|
||||
depname, depdesc, depcond = parse_dep(depstring)
|
||||
assert depname == exp_depname
|
||||
assert depdesc == exp_depdesc
|
||||
assert depcond == exp_depcond
|
||||
|
|
Loading…
Add table
Reference in a new issue