Changeset View
Changeset View
Standalone View
Standalone View
lilybuild/lilybuild/tests/helpers_test.py
| import unittest | import unittest | ||||
| import json | import json | ||||
| from lilybuild.ci_syntax.ci_file import CIFile | from lilybuild.ci_syntax.ci_file import CIFile | ||||
| from lilybuild.helpers import ( | from lilybuild.helpers import ( | ||||
| rsync_rules_from_artifacts, | rsync_rules_from_artifacts, | ||||
| normalize_base_url, | normalize_base_url, | ||||
| phorge_token_to_arcrc, | phorge_token_to_arcrc, | ||||
| ci_vars_to_cmds, | ci_vars_to_cmds, | ||||
| get_job_script, | get_job_script, | ||||
| DEFAULT_SCRIPT_HEADER, | DEFAULT_SCRIPT_HEADER, | ||||
| normalize_image, | |||||
| ) | ) | ||||
| from lilybuild.tests.resources import get_res | from lilybuild.tests.resources import get_res | ||||
| class RsyncRulesTest(unittest.TestCase): | class RsyncRulesTest(unittest.TestCase): | ||||
| def test_empty(self): | def test_empty(self): | ||||
| self.assertEqual( | self.assertEqual( | ||||
| rsync_rules_from_artifacts({}), | rsync_rules_from_artifacts({}), | ||||
| ['--include', '*/', '--exclude', '*'] | ['--include', '*/', '--exclude', '*'] | ||||
| ▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | |||||
| set +e | set +e | ||||
| find | find | ||||
| echo ok | echo ok | ||||
| exit 0''') | exit 0''') | ||||
| class NormalizeImageTest(unittest.TestCase): | |||||
| def test_str(self): | |||||
| res = normalize_image('alpine') | |||||
| self.assertEqual(json.loads(res), {'name': 'alpine'}) | |||||
| def test_object(self): | |||||
| orig = {'name': 'alpine', 'entrypoint': ['/docker-run', '/bin/bb']} | |||||
| res = normalize_image(orig) | |||||
| self.assertEqual(json.loads(res), orig) | |||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||
| unittest.main() | unittest.main() | ||||