mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 07:46:09 +01:00
Merge pull request #172563 from pimeys/prisma-tests
This commit is contained in:
commit
da20988217
2 changed files with 62 additions and 0 deletions
|
@ -339,6 +339,12 @@ let
|
|||
--set PRISMA_INTROSPECTION_ENGINE_BINARY ${prisma-engines}/bin/introspection-engine \
|
||||
--set PRISMA_FMT_BINARY ${prisma-engines}/bin/prisma-fmt
|
||||
'';
|
||||
|
||||
passthru.tests = {
|
||||
simple-execution = pkgs.callPackage ./package-tests/prisma.nix {
|
||||
inherit (self) prisma;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
pulp = super.pulp.override {
|
||||
|
|
56
pkgs/development/node-packages/package-tests/prisma.nix
Normal file
56
pkgs/development/node-packages/package-tests/prisma.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{ lib, pkgs, runCommand, prisma }:
|
||||
|
||||
let
|
||||
inherit (prisma) packageName;
|
||||
prismaMajorVersion = lib.versions.majorMinor prisma.version;
|
||||
enginesMajorVersion = lib.versions.majorMinor pkgs.prisma-engines.version;
|
||||
in
|
||||
|
||||
runCommand "${packageName}-tests" {
|
||||
nativeBuildInputs = with pkgs; [ prisma sqlite-interactive ];
|
||||
meta.timeout = 60;
|
||||
}
|
||||
''
|
||||
mkdir $out
|
||||
cd $out
|
||||
|
||||
if [ "${prismaMajorVersion}" != "${enginesMajorVersion}" ]; then
|
||||
echo "nodePackages.prisma in version ${prismaMajorVersion} and prisma-engines in ${enginesMajorVersion}. Major versions must match."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure CLI runs
|
||||
prisma --help > /dev/null
|
||||
|
||||
# Init a new project
|
||||
prisma init > /dev/null
|
||||
|
||||
# Create a simple data model
|
||||
cat << EOF > prisma/schema.prisma
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = "file:test.db"
|
||||
}
|
||||
|
||||
generator js {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
model A {
|
||||
id Int @id @default(autoincrement())
|
||||
b String @default("foo")
|
||||
}
|
||||
EOF
|
||||
|
||||
# Format
|
||||
prisma format > /dev/null
|
||||
|
||||
# Create the database
|
||||
prisma db push --skip-generate > /dev/null
|
||||
|
||||
# The database file should exist and be a SQLite database
|
||||
sqlite3 prisma/test.db "SELECT id, b FROM A" > /dev/null
|
||||
|
||||
# Introspect the database
|
||||
prisma db pull > /dev/null
|
||||
''
|
Loading…
Reference in a new issue