Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
45 lines
2.1 KiB
Python
45 lines
2.1 KiB
Python
import copy
|
|
import io
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from read_dependencies import validate_pins, verify_checkouts, write_outputs
|
|
|
|
|
|
class DependencyPinsTests(unittest.TestCase):
|
|
def setUp(self):
|
|
self.pins = {'schemaVersion': 1,
|
|
'core': {'repository': 'lingjhf/cutdex_core', 'revision': 'a' * 40},
|
|
'nativeFlutter': {'repository': 'cutdex-native/cutdex_native_flutter',
|
|
'revision': 'b' * 40, 'version': '0.0.1', 'ref': 'v0.0.1'}}
|
|
|
|
def test_development_commit_and_release_tag_outputs(self):
|
|
output = io.StringIO()
|
|
write_outputs(self.pins, output)
|
|
self.assertIn('core-ref=' + 'a' * 40 + '\n', output.getvalue())
|
|
self.assertIn('nativeFlutter-ref=v0.0.1\n', output.getvalue())
|
|
self.assertIn('nativeFlutter-revision=' + 'b' * 40 + '\n', output.getvalue())
|
|
|
|
def test_unpinned_branch_mismatched_version_and_invalid_identity_are_rejected(self):
|
|
for field, value in (('ref', 'main'), ('ref', 'v0.0.2'), ('version', '0.0.1\ninjected=true'),
|
|
('revision', 'short'), ('repository', 'owner/repo\ninjected=true')):
|
|
pins = copy.deepcopy(self.pins)
|
|
pins['nativeFlutter'][field] = value
|
|
with self.subTest(field=field, value=value), self.assertRaises(ValueError):
|
|
validate_pins(pins)
|
|
|
|
def test_mutated_release_tag_cannot_change_dependency_commit(self):
|
|
with patch('read_dependencies.subprocess.check_output', side_effect=['a' * 40, 'c' * 40]):
|
|
with self.assertRaisesRegex(ValueError, 'nativeFlutter: checkout'):
|
|
verify_checkouts(self.pins)
|
|
|
|
def test_both_dependency_commits_are_checked_in_their_own_checkouts(self):
|
|
with patch('read_dependencies.subprocess.check_output', side_effect=['a' * 40, 'b' * 40]) as git:
|
|
verify_checkouts(self.pins)
|
|
self.assertEqual([call.kwargs['cwd'].name for call in git.call_args_list],
|
|
['cutdex_core', 'cutdex_native_flutter'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|