Skip to content
Snippets Groups Projects
Commit 9a1fb101 authored by Simon Rose's avatar Simon Rose
Browse files

patching kinda works now

parent d728c392
No related branches found
No related tags found
1 merge request!38E3-233: Add tests
...@@ -8,6 +8,24 @@ from .utils import * ...@@ -8,6 +8,24 @@ from .utils import *
TEST_DATA = Path(__file__).absolute().parent / "data" 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( @pytest.mark.parametrize(
...@@ -16,22 +34,31 @@ TEST_DATA = Path(__file__).absolute().parent / "data" ...@@ -16,22 +34,31 @@ TEST_DATA = Path(__file__).absolute().parent / "data"
indirect=True, indirect=True,
) )
def test_patch(wrapper): 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( rc, outs, _ = run_make(
wrapper_dir, wrapper,
"init", "init",
__DEBUG_VERSION="0.0.0", __DEBUG_VERSION=MODULE_VERSION,
) )
assert rc == 0 assert rc == 0
assert "You are in the local source mode" in outs.decode("utf-8") 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 assert rc == 0
with open(wrapper_dir / "build" / "database.db", "r") as f: with open(db_path, "r") as f:
db_contents = f.read() db_contents = f.read()
assert 'field(DESC, "OK")' in db_contents assert 'field(DESC, "OK")' in db_contents
assert not "Bad" in db_contents assert not "Bad" in db_contents
run_make(wrapper_dir, "build") run_make(wrapper, "build")
assert any((wrapper_dir / "build").glob("O.*")) assert any((wrapper / "build").glob("O.*"))
...@@ -8,8 +8,6 @@ from .utils import * ...@@ -8,8 +8,6 @@ from .utils import *
TEST_DATA = Path(__file__).absolute().parent / "data" TEST_DATA = Path(__file__).absolute().parent / "data"
TEST_MODULE_NAME = "testversions"
RE_MODULE_LOADED = f"Loaded {TEST_MODULE_NAME} version {{version}}" 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\\))" RE_MODULE_NOT_LOADED = f"Module {TEST_MODULE_NAME} (not available|version {{required}} not available|version {{required}} not available \\(but other versions are available\\))"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment