diff --git a/tests/test_build.py b/tests/test_build.py index c07c9bd4915c8d7e64ea2fe5b29d3b3687e80df8..a0dcfdb1d48ca94ffd7ee909bc5825eaf06e29ab 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -8,6 +8,24 @@ from .utils import * TEST_DATA = Path(__file__).absolute().parent / "data" +MODULE_VERSION = "0.0.0+0" + +DB_FILE = """record(ai, "TEST") { + +} +""" + +PATCH_FILE = """ +diff --git database.db database.db +index 1806ff6..8701832 100644 +--- database.db ++++ database.db +@@ -1,3 +1,3 @@ + record(ai, "TEST") {{ +- ++ field(DESC, "{desc}") + }} +""" @pytest.mark.parametrize( @@ -16,22 +34,31 @@ TEST_DATA = Path(__file__).absolute().parent / "data" indirect=True, ) def test_patch(wrapper): - wrapper_dir = wrapper + db_path = wrapper / TEST_MODULE_NAME / "database.db" + with open(db_path, "w") as f: + f.write(DB_FILE) + + patch_path = wrapper / "patch" / "Site" / MODULE_VERSION / "apply.p0.patch" + patch_path.parent.mkdir(parents=True) + with open(patch_path, "w") as f: + f.write(PATCH_FILE.format(desc="OK")) rc, outs, _ = run_make( - wrapper_dir, + wrapper, "init", - __DEBUG_VERSION="0.0.0", + __DEBUG_VERSION=MODULE_VERSION, ) assert rc == 0 assert "You are in the local source mode" in outs.decode("utf-8") - rc, _, _ = run_make(wrapper_dir, "patch") + rc, outs, errs = run_make(wrapper, "patch", __DEBUG_VERSION=MODULE_VERSION) + print(outs) + print(errs) assert rc == 0 - with open(wrapper_dir / "build" / "database.db", "r") as f: + with open(db_path, "r") as f: db_contents = f.read() assert 'field(DESC, "OK")' in db_contents assert not "Bad" in db_contents - run_make(wrapper_dir, "build") - assert any((wrapper_dir / "build").glob("O.*")) + run_make(wrapper, "build") + assert any((wrapper / "build").glob("O.*")) diff --git a/tests/test_versions.py b/tests/test_versions.py index 6d18e3d6046b92a2ea97f0bea520007c2a9da6f5..84e5adc7aaa5288bbae7677e6c813ca87b6dcdb0 100644 --- a/tests/test_versions.py +++ b/tests/test_versions.py @@ -8,8 +8,6 @@ from .utils import * TEST_DATA = Path(__file__).absolute().parent / "data" -TEST_MODULE_NAME = "testversions" - RE_MODULE_LOADED = f"Loaded {TEST_MODULE_NAME} version {{version}}" RE_MODULE_NOT_LOADED = f"Module {TEST_MODULE_NAME} (not available|version {{required}} not available|version {{required}} not available \\(but other versions are available\\))"