Skip to content

Commit

Permalink
feat: util_test
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmaestro committed Dec 3, 2024
1 parent 1661d38 commit ff8eb6c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apt/tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load(":apt_deb_repository_test.bzl", "apt_deb_repository_tests")
load(":apt_dep_resolver_test.bzl", "apt_dep_resolver_tests")
load(":nested_dict_test.bzl", "nested_dict_tests")
load(":util_test.bzl", "util_tests")
load(":version_constraint_test.bzl", "version_constraint_tests")
load(":version_test.bzl", "version_tests")

Expand All @@ -10,6 +11,8 @@ apt_dep_resolver_tests()

nested_dict_tests()

util_tests()

version_tests()

version_constraint_tests()
26 changes: 26 additions & 0 deletions apt/tests/util_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"unit tests for util"

load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
load("//apt/private:util.bzl", "util")

_TEST_SUITE_PREFIX = "util/"

def _sanitize_test(ctx):
env = unittest.begin(ctx)

parameters = {
"3.0.6+dfsg-4": "3.0.6-p-dfsg-4",
"8.8.1+ds+~cs25.17.7-2": "8.8.1-p-ds-p-_cs25.17.7-2",
"1:2020.1commit85143dcb-4": "1-2020.1commit85143dcb-4",
}

for s, expected in parameters.items():
actual = util.sanitize(s)
asserts.equals(env, expected, actual)

return unittest.end(env)

sanitize_test = unittest.make(_sanitize_test)

def util_tests():
sanitize_test(name = _TEST_SUITE_PREFIX + "sanitize")

0 comments on commit ff8eb6c

Please sign in to comment.