debian-forge/test/run/test_executable.py
Lars Karlitski f7949d9993 test: add test for osbuild executable
Add two simple tests to check that the osbuild executable fails with the
right exit codes when passed an invalid manifest or checkpoint.

This reuses test.OSBuild, which is extended to raise CalledProcessError
if needed.
2020-10-27 22:04:09 +01:00

30 lines
812 B
Python

#
# Runtime Tests for the `osbuild` executable
#
import json
import subprocess
import unittest
from .. import test
class TestExecutable(unittest.TestCase):
def setUp(self):
self.osbuild = test.OSBuild(self)
def test_invalid_manifest(self):
invalid = json.dumps({"foo": 42})
with self.osbuild as osb, self.assertRaises(subprocess.CalledProcessError) as e:
osb.compile(invalid, check=True)
self.assertEqual(e.exception.returncode, 2)
def test_invalid_checkpoint(self):
manifest = json.dumps({})
with self.osbuild as osb, self.assertRaises(subprocess.CalledProcessError) as e:
osb.compile(manifest, checkpoints=["f44f76973fb92446a2a33bfdb401361a47f70497"], check=True)
self.assertEqual(e.exception.returncode, 1)