fix(test): Clear previous prometheus data for test

It could happen that test data is already generated by a previous test.
(running in the same worker)

Make sure we clear everything before performing our checks.

Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-08-26 17:08:36 +02:00
parent 5699e9bb41
commit 1433553c05
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296

View file

@ -1,7 +1,7 @@
import pytest
from prometheus_client import REGISTRY, generate_latest
from aurweb import cache, db, time
from aurweb import cache, db, prometheus, time
from aurweb.models import Package, PackageBase, PackageRequest
from aurweb.models.account_type import TRUSTED_USER_ID, USER_ID
from aurweb.models.package_request import (
@ -140,6 +140,11 @@ def test_get_count_change(stats: Statistics, test_data):
def test_update_prometheus_metrics(test_data):
# Make sure any previous data is cleared
prometheus.USERS.clear()
prometheus.PACKAGES.clear()
prometheus.REQUESTS.clear()
metrics = str(generate_latest(REGISTRY))
assert "aur_users{" not in metrics