Add unit tests
This commit is contained in:
parent
79c18a58f2
commit
009158ee4d
1 changed files with 20 additions and 0 deletions
20
tests/test_slo_tracker.py
Normal file
20
tests/test_slo_tracker.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
from slo_tracker import evaluate_slo
|
||||||
|
|
||||||
|
|
||||||
|
def make_prom(value):
|
||||||
|
prom = MagicMock()
|
||||||
|
prom.custom_query.return_value = [{"value": [0, str(value)]}]
|
||||||
|
return prom
|
||||||
|
|
||||||
|
|
||||||
|
def test_slo_ok():
|
||||||
|
slo = {"name": "test", "query": "up", "target": 0.99}
|
||||||
|
result = evaluate_slo(make_prom(0.999), slo, "7d")
|
||||||
|
assert result["ok"] is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_slo_burning():
|
||||||
|
slo = {"name": "test", "query": "up", "target": 0.99}
|
||||||
|
result = evaluate_slo(make_prom(0.985), slo, "7d")
|
||||||
|
assert result["ok"] is False
|
||||||
Loading…
Reference in a new issue