2020-10-05 17:38:14 +00:00
|
|
|
# MIT licensed
|
|
|
|
# Copyright (c) 2020 Chih-Hsuan Yen <yan12125 at gmail dot com>
|
|
|
|
|
|
|
|
import pytest
|
2023-12-02 15:45:25 +00:00
|
|
|
import datetime
|
2024-11-03 10:29:19 +00:00
|
|
|
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
|
2020-10-05 17:38:14 +00:00
|
|
|
|
|
|
|
async def test_container(get_version):
|
|
|
|
assert await get_version("hello-world", {
|
|
|
|
"source": "container",
|
|
|
|
"container": "library/hello-world",
|
|
|
|
"include_regex": "linux",
|
|
|
|
}) == "linux"
|
2021-06-06 04:12:07 +00:00
|
|
|
|
2023-12-02 15:45:25 +00:00
|
|
|
async def test_container_with_tag(get_version):
|
2023-12-18 06:58:56 +00:00
|
|
|
update_time = await get_version("bitnami/mongodb:5.0", {
|
|
|
|
"source": "container",
|
|
|
|
"container": "bitnami/mongodb:5.0",
|
|
|
|
})
|
|
|
|
# the update time is changing occasionally, so we can not compare the exact time, otherwise the test will be failed in the future
|
|
|
|
assert datetime.date.fromisoformat(update_time.split('T')[0]) > datetime.date(2023, 12, 1)
|
|
|
|
|
|
|
|
async def test_container_with_tag_and_multi_arch(get_version):
|
2023-12-02 15:45:25 +00:00
|
|
|
update_time = await get_version("hello-world:linux", {
|
|
|
|
"source": "container",
|
|
|
|
"container": "library/hello-world:linux",
|
|
|
|
})
|
|
|
|
# the update time is changing occasionally, so we can not compare the exact time, otherwise the test will be failed in the future
|
|
|
|
assert datetime.date.fromisoformat(update_time.split('T')[0]) > datetime.date(2023, 1, 1)
|
|
|
|
|
|
|
|
async def test_container_with_tag_and_registry(get_version):
|
|
|
|
update_time = await get_version("hello-world-nginx:v1.0", {
|
|
|
|
"source": "container",
|
|
|
|
"registry": "quay.io",
|
|
|
|
"container": "redhattraining/hello-world-nginx:v1.0",
|
|
|
|
})
|
|
|
|
# the update time probably won't be changed
|
|
|
|
assert datetime.date.fromisoformat(update_time.split('T')[0]) == datetime.date(2019, 6, 26)
|
|
|
|
|
2021-06-06 04:12:07 +00:00
|
|
|
async def test_container_paging(get_version):
|
|
|
|
assert await get_version("prometheus-operator", {
|
|
|
|
"source": "container",
|
2021-06-06 04:26:44 +00:00
|
|
|
"registry": "quay.io",
|
2021-08-22 14:43:33 +00:00
|
|
|
"container": "redhattraining/hello-world-nginx",
|
|
|
|
}) == "v1.0"
|