Propagate return code

Previously the results were only being printed, but the return code
for the checks wasn't propagated up.
This commit is contained in:
Ben Nemec 2018-09-13 17:19:36 +00:00
parent 8d76949735
commit d3877b9087
3 changed files with 7 additions and 4 deletions

View File

@ -14,6 +14,8 @@
"""Example CLI command for running upgrade checks"""
import sys
from oslo_upgradecheck import upgradecheck
@ -33,8 +35,8 @@ class Checks(upgradecheck.UpgradeCommands):
def main():
inst = Checks()
upgradecheck.main(inst.check)
return upgradecheck.main(inst.check)
if __name__ == '__main__':
main()
sys.exit(main())

View File

@ -77,4 +77,5 @@ class TestMain(base.BaseTestCase):
mock_argv = ['test-status', 'upgrade', 'check']
with mock.patch.object(sys, 'argv', mock_argv, create=True):
inst = TestCommands()
upgradecheck.main(inst.check)
result = upgradecheck.main(inst.check)
self.assertEqual(upgradecheck.UpgradeCheckCode.FAILURE, result)

View File

@ -148,4 +148,4 @@ def main(check_callback):
conf.register_cli_opt(opt)
conf(sys.argv[1:])
conf.category.action_fn()
return conf.category.action_fn()