nvchecker/tests/test_go.py

37 lines
811 B
Python
Raw Normal View History

2024-03-09 10:41:20 +00:00
# MIT licensed
# Copyright (c) 2024 bgme <i@bgme.me>.
import pytest
from nvchecker.api import HTTPError
try:
2024-03-09 10:48:47 +00:00
import lxml
lxml_available = True
2024-03-09 10:41:20 +00:00
except ImportError:
2024-03-09 10:48:47 +00:00
lxml_available = False
2024-03-09 10:41:20 +00:00
pytestmark = [
2024-03-09 10:48:47 +00:00
pytest.mark.asyncio(scope="session"),
pytest.mark.needs_net,
pytest.mark.skipif(not lxml_available, reason="needs lxml")
2024-03-09 10:41:20 +00:00
]
async def test_go(get_version):
2024-03-09 10:48:47 +00:00
assert await get_version("one version", {
"source": "go",
"go": "github.com/caddyserver/replace-response",
}) == "v0.0.0-20231221003037-a85d4ddc11d6"
assert await get_version("multiple version", {
"source": "go",
"go": "github.com/corazawaf/coraza-caddy",
}) == "v1.2.2"
with pytest.raises(HTTPError):
await get_version("not found", {
"source": "go",
"go": "github.com/asdas/sadfasdf",
})