Remove ./test (./example has a test now)

This commit is contained in:
Sridhar Ratnakumar 2023-06-13 18:13:30 -04:00
parent e86d5cb68c
commit 6d6303a912
5 changed files with 13 additions and 166 deletions

View File

@ -14,5 +14,5 @@ jobs:
- name: Run test
id: test
run: |
./test/test.sh
./test.sh

12
test.sh Executable file
View File

@ -0,0 +1,12 @@
set -euxo pipefail
cd "$(dirname "$0")"
cd ./example
# First, build the example.
nix build -L --no-link --print-out-paths --override-input process-compose-flake ..
# When on NixOS, run the VM tests to test runtime behaviour
if command -v nixos-rebuild &> /dev/null; then
nix flake check -L --override-input process-compose-flake ..
fi

View File

@ -1,96 +0,0 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1685662779,
"narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1686089707,
"narHash": "sha256-LTNlJcru2qJ0XhlhG9Acp5KyjB774Pza3tRH0pKIb3o=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "af21c31b2a1ec5d361ed8050edd0303c31306397",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1685564631,
"narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"process-compose-flake": {
"locked": {
"lastModified": 1686334385,
"narHash": "sha256-s1J8g2dJM5d4Ubl56td/Hv5tgGI+Iu6j9yGzFKdHcZg=",
"owner": "Platonic-Systems",
"repo": "process-compose-flake",
"rev": "d6723f2de324522d5dc900bae42f5a506d3f1f78",
"type": "github"
},
"original": {
"owner": "Platonic-Systems",
"repo": "process-compose-flake",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"process-compose-flake": "process-compose-flake",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,58 +0,0 @@
{
description = "process-compose-flake test";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.process-compose-flake.flakeModule
];
perSystem = { pkgs, lib, ... }: {
# This adds a `self.packages.default`
process-compose."default" = {
debug = true;
tui = false;
settings = {
environment = [
"DATAFILE=data.sqlite"
];
processes = {
# Create a simple sqlite db
sqlite-init.command =
let
sqlFile = pkgs.writeTextFile {
name = "data.sql";
text = ''
CREATE TABLE demo (val TEXT);
INSERT INTO demo VALUES ("Hello");
'';
};
in
''
echo "$(date): Creating database ($DATAFILE) ..."
${lib.getExe pkgs.sqlite} "$DATAFILE" < ${sqlFile}
echo "$(date): Done."
'';
# Query something, write to result.txt
sqlite-query = {
command = ''
${lib.getExe pkgs.sqlite} "$DATAFILE" \
'select val from demo where val = "Hello"' \
> result.txt
'';
# The 'depends_on' will have this process wait until the above one is completed.
depends_on."sqlite-init".condition = "process_completed_successfully";
availability.restart = "no";
};
};
};
};
};
};
}

View File

@ -1,11 +0,0 @@
set -euxo pipefail
cd "$(dirname "$0")"
# First, build the example.
(cd ../example && nix build -L --override-input process-compose-flake ..)
# Then run the test.
rm -f ./data.sqlite ./result.txt
nix run -L --override-input process-compose-flake .. .
[[ $(cat result.txt) == "Hello" ]] && echo "Test passed" || (echo "Test failed" && exit 1)