mob next [ci-skip] [ci skip] [skip ci]
lastFile:tests/lib.nix
This commit is contained in:
16
tests/default.nix
Normal file
16
tests/default.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{ self, ... }:
|
||||
{
|
||||
perSystem =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
checks =
|
||||
let
|
||||
checkArgs = {
|
||||
inherit pkgs self;
|
||||
};
|
||||
in
|
||||
{
|
||||
think-gtcm = import ./tests/think-gtcm.nix checkArgs;
|
||||
};
|
||||
};
|
||||
}
|
||||
18
tests/lib.nix
Normal file
18
tests/lib.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
test:
|
||||
# These arguments are provided by `flake.nix` on import, see checkArgs
|
||||
{ pkgs, self }:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
# this imports the nixos library that contains our testing framework
|
||||
nixos-lib = import (pkgs.path + "/nixos/lib") { };
|
||||
in
|
||||
(nixos-lib.runTest {
|
||||
hostPkgs = pkgs;
|
||||
# This speeds up the evaluation by skipping evaluating documentation (optional)
|
||||
defaults.documentation.enable = lib.mkDefault false;
|
||||
# This makes `self` available in the NixOS configuration of our virtual machines.
|
||||
# This is useful for referencing modules or packages from your own flake
|
||||
# as well as importing from other flakes.
|
||||
node.specialArgs = { inherit self; };
|
||||
imports = [ test ];
|
||||
}).config.result
|
||||
23
tests/tests/think-gtcm.nix
Normal file
23
tests/tests/think-gtcm.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
(import ../lib.nix) {
|
||||
name = "think-gtcm";
|
||||
nodes = {
|
||||
# `self` here is set by using specialArgs in `lib.nix`
|
||||
node1 =
|
||||
{ self, pkgs, ... }:
|
||||
{
|
||||
nixpkgs.overlays = [ self.overlays.packagesOverlay ];
|
||||
imports = [ self.nixosModules.think-gtcm ];
|
||||
services.think-greaterchiangmai = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
# This is the test code that will check if our service is running correctly:
|
||||
testScript = ''
|
||||
start_all()
|
||||
|
||||
node1.wait_for_unit("phpfpm-think-greaterchiangmai")
|
||||
node1.wait_for_open_port(80)
|
||||
output = node1.succeed("curl localhost")
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user