mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 04:02:55 +03:00
25bef2d8f9
The library does not depend on stdenv, that `stdenv` exposes `lib` is an artifact of the ancient origins of nixpkgs.
59 lines
1.5 KiB
Nix
59 lines
1.5 KiB
Nix
import ./make-test-python.nix ({ pkgs, ...} :
|
|
|
|
let
|
|
port = 10004;
|
|
tcpPort = 10005;
|
|
httpPort = 10080;
|
|
in {
|
|
name = "snapcast";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ hexa ];
|
|
};
|
|
|
|
nodes = {
|
|
server = {
|
|
services.snapserver = {
|
|
enable = true;
|
|
port = port;
|
|
tcp.port = tcpPort;
|
|
http.port = httpPort;
|
|
streams = {
|
|
mpd = {
|
|
type = "pipe";
|
|
location = "/run/snapserver/mpd";
|
|
};
|
|
bluetooth = {
|
|
type = "pipe";
|
|
location = "/run/snapserver/bluetooth";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
import json
|
|
|
|
get_rpc_version = {"id": "1", "jsonrpc": "2.0", "method": "Server.GetRPCVersion"}
|
|
|
|
start_all()
|
|
|
|
server.wait_for_unit("snapserver.service")
|
|
server.wait_until_succeeds("ss -ntl | grep -q ${toString port}")
|
|
server.wait_until_succeeds("ss -ntl | grep -q ${toString tcpPort}")
|
|
server.wait_until_succeeds("ss -ntl | grep -q ${toString httpPort}")
|
|
|
|
with subtest("check that pipes are created"):
|
|
server.succeed("test -p /run/snapserver/mpd")
|
|
server.succeed("test -p /run/snapserver/bluetooth")
|
|
|
|
with subtest("test tcp json-rpc"):
|
|
server.succeed(f"echo '{json.dumps(get_rpc_version)}' | nc -w 1 localhost ${toString tcpPort}")
|
|
|
|
with subtest("test http json-rpc"):
|
|
server.succeed(
|
|
"curl --fail http://localhost:${toString httpPort}/jsonrpc -d '{json.dumps(get_rpc_version)}'"
|
|
)
|
|
'';
|
|
})
|