Move label validation tests into pytest

This commit is contained in:
Joseph Schorr 2018-07-19 11:16:33 -04:00
parent a5dc885fc6
commit b69af403d4
2 changed files with 34 additions and 45 deletions

View file

@ -1,6 +1,7 @@
import pytest
from util.validation import is_json
from util.validation import is_json, validate_label_key
@pytest.mark.parametrize('string_value,expected', [
('{}', True),
@ -15,3 +16,35 @@ from util.validation import is_json
])
def test_is_json(string_value, expected):
assert is_json(string_value) == expected
@pytest.mark.parametrize('key, is_valid', [
('foo', True),
('bar', True),
('foo1', True),
('bar2', True),
('1', True),
('12', True),
('123', True),
('1234', True),
('git-sha', True),
('com.coreos.something', True),
('io.quay.git-sha', True),
('', False),
('git_sha', False),
('-125', False),
('-foo', False),
('foo-', False),
('123-', False),
('foo--bar', False),
('foo..bar', False),
])
def test_validate_label_key(key, is_valid):
assert validate_label_key(key) == is_valid