minecraft-server: Add test
This commit is contained in:
parent
0dc74a15ad
commit
13ebb30910
@ -209,6 +209,7 @@ in
|
||||
memcached = handleTest ./memcached.nix {};
|
||||
metabase = handleTest ./metabase.nix {};
|
||||
minecraft = handleTest ./minecraft.nix {};
|
||||
minecraft-server = handleTest ./minecraft-server.nix {};
|
||||
miniflux = handleTest ./miniflux.nix {};
|
||||
minio = handleTest ./minio.nix {};
|
||||
minidlna = handleTest ./minidlna.nix {};
|
||||
|
37
nixos/tests/minecraft-server.nix
Normal file
37
nixos/tests/minecraft-server.nix
Normal file
@ -0,0 +1,37 @@
|
||||
let
|
||||
seed = "2151901553968352745";
|
||||
rcon-pass = "foobar";
|
||||
rcon-port = 43000;
|
||||
in import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "minecraft-server";
|
||||
meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; };
|
||||
|
||||
nodes.server = { ... }: {
|
||||
environment.systemPackages = [ pkgs.mcrcon ];
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
services.minecraft-server = {
|
||||
declarative = true;
|
||||
enable = true;
|
||||
eula = true;
|
||||
serverProperties = {
|
||||
enable-rcon = true;
|
||||
level-seed = seed;
|
||||
online-mode = false;
|
||||
"rcon.password" = rcon-pass;
|
||||
"rcon.port" = rcon-port;
|
||||
};
|
||||
};
|
||||
|
||||
virtualisation.memorySize = 2048;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
server.wait_for_unit("minecraft-server")
|
||||
server.wait_for_open_port(${toString rcon-port})
|
||||
assert "${seed}" in server.succeed(
|
||||
"mcrcon -H localhost -P ${toString rcon-port} -p '${rcon-pass}' -c 'seed'"
|
||||
)
|
||||
'';
|
||||
})
|
@ -1,4 +1,4 @@
|
||||
{ stdenv, fetchurl, jre_headless }:
|
||||
{ stdenv, fetchurl, nixosTests, jre_headless }:
|
||||
stdenv.mkDerivation {
|
||||
pname = "minecraft-server";
|
||||
version = "1.16.4";
|
||||
@ -25,7 +25,10 @@ stdenv.mkDerivation {
|
||||
|
||||
phases = "installPhase";
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
passthru = {
|
||||
tests = { inherit (nixosTests) minecraft-server; };
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "Minecraft Server";
|
||||
|
Loading…
Reference in New Issue
Block a user