From 51d5121a5cd3733ef34d89cbbc4a2fca22dd83d9 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Mon, 18 Dec 2023 09:28:43 -0700 Subject: [PATCH] integration-tests/basic: Dump schema after test Not doing anything with the dumped schema yet, but we will have automated checks to ensure the schema isn't changed in an incompatible way. --- integration-tests/basic/default.nix | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/integration-tests/basic/default.nix b/integration-tests/basic/default.nix index 2b029e1..ac26d52 100644 --- a/integration-tests/basic/default.nix +++ b/integration-tests/basic/default.nix @@ -29,7 +29,18 @@ let ''; databaseModules = { - sqlite = {}; + sqlite = { + testScriptPost = '' + from pathlib import Path + import os + + schema = server.succeed("${pkgs.sqlite}/bin/sqlite3 /var/lib/atticd/server.db '.schema --indent'") + + schema_path = Path(os.environ.get("out", os.getcwd())) / "schema.sql" + with open(schema_path, 'w') as f: + f.write(schema) + ''; + }; postgres = { server = { services.postgresql = { @@ -57,6 +68,16 @@ let database.url = "postgresql:///attic?host=/run/postgresql"; }; }; + testScriptPost = '' + from pathlib import Path + import os + + schema = server.succeed("pg_dump --schema-only attic") + + schema_path = Path(os.environ.get("out", os.getcwd())) / "schema.sql" + with open(schema_path, 'w') as f: + f.write(schema) + ''; }; }; @@ -229,6 +250,9 @@ in { client.succeed("attic cache destroy --no-confirm test") client.fail("attic cache info test") client.fail("curl -sL --fail-with-body http://server:8080/test/nix-cache-info") + + ${databaseModules.${config.database}.testScriptPost or ""} + ${storageModules.${config.storage}.testScriptPost or ""} ''; }; }