1
0
Fork 0
mirror of https://github.com/zhaofengli/attic.git synced 2024-12-14 11:57:30 +00:00

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.
This commit is contained in:
Zhaofeng Li 2023-12-18 09:28:43 -07:00
parent e9918bc6be
commit 51d5121a5c

View file

@ -29,7 +29,18 @@ let
''; '';
databaseModules = { 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 = { postgres = {
server = { server = {
services.postgresql = { services.postgresql = {
@ -57,6 +68,16 @@ let
database.url = "postgresql:///attic?host=/run/postgresql"; 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.succeed("attic cache destroy --no-confirm test")
client.fail("attic cache info test") client.fail("attic cache info test")
client.fail("curl -sL --fail-with-body http://server:8080/test/nix-cache-info") client.fail("curl -sL --fail-with-body http://server:8080/test/nix-cache-info")
${databaseModules.${config.database}.testScriptPost or ""}
${storageModules.${config.storage}.testScriptPost or ""}
''; '';
}; };
} }