mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-11 07:15:54 +03:00
nixos/mihomo: add tests
This commit is contained in:
parent
a5d09a41b0
commit
84bbdc744e
@ -528,6 +528,7 @@ in {
|
|||||||
memcached = handleTest ./memcached.nix {};
|
memcached = handleTest ./memcached.nix {};
|
||||||
merecat = handleTest ./merecat.nix {};
|
merecat = handleTest ./merecat.nix {};
|
||||||
metabase = handleTest ./metabase.nix {};
|
metabase = handleTest ./metabase.nix {};
|
||||||
|
mihomo = handleTest ./mihomo.nix {};
|
||||||
mindustry = handleTest ./mindustry.nix {};
|
mindustry = handleTest ./mindustry.nix {};
|
||||||
minecraft = handleTest ./minecraft.nix {};
|
minecraft = handleTest ./minecraft.nix {};
|
||||||
minecraft-server = handleTest ./minecraft-server.nix {};
|
minecraft-server = handleTest ./minecraft-server.nix {};
|
||||||
|
44
nixos/tests/mihomo.nix
Normal file
44
nixos/tests/mihomo.nix
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import ./make-test-python.nix ({ pkgs, ... }: {
|
||||||
|
name = "mihomo";
|
||||||
|
meta.maintainers = with pkgs.lib.maintainers; [ Guanran928 ];
|
||||||
|
|
||||||
|
nodes.machine = {
|
||||||
|
environment.systemPackages = [ pkgs.curl ];
|
||||||
|
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
statusPage = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.mihomo = {
|
||||||
|
enable = true;
|
||||||
|
configFile = pkgs.writeTextFile {
|
||||||
|
name = "config.yaml";
|
||||||
|
text = ''
|
||||||
|
mixed-port: 7890
|
||||||
|
external-controller: 127.0.0.1:9090
|
||||||
|
authentication:
|
||||||
|
- "user:supersecret"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
# Wait until it starts
|
||||||
|
machine.wait_for_unit("nginx.service")
|
||||||
|
machine.wait_for_unit("mihomo.service")
|
||||||
|
machine.wait_for_open_port(80)
|
||||||
|
machine.wait_for_open_port(7890)
|
||||||
|
machine.wait_for_open_port(9090)
|
||||||
|
|
||||||
|
# Proxy
|
||||||
|
machine.succeed("curl --fail --max-time 10 --proxy http://user:supersecret@localhost:7890 http://localhost")
|
||||||
|
machine.succeed("curl --fail --max-time 10 --proxy socks5://user:supersecret@localhost:7890 http://localhost")
|
||||||
|
machine.fail("curl --fail --max-time 10 --proxy http://user:supervillain@localhost:7890 http://localhost")
|
||||||
|
machine.fail("curl --fail --max-time 10 --proxy socks5://user:supervillain@localhost:7890 http://localhost")
|
||||||
|
|
||||||
|
# Web UI
|
||||||
|
machine.succeed("curl --fail http://localhost:9090") == '{"hello":"clash"}'
|
||||||
|
'';
|
||||||
|
})
|
@ -1,6 +1,7 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, buildGoModule
|
, buildGoModule
|
||||||
|
, nixosTests
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildGoModule rec {
|
buildGoModule rec {
|
||||||
@ -31,6 +32,11 @@ buildGoModule rec {
|
|||||||
# network required
|
# network required
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
|
|
||||||
|
passthru.tests = {
|
||||||
|
mihomo = nixosTests.mihomo;
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A rule-based tunnel in Go";
|
description = "A rule-based tunnel in Go";
|
||||||
homepage = "https://github.com/MetaCubeX/mihomo";
|
homepage = "https://github.com/MetaCubeX/mihomo";
|
||||||
|
Loading…
Reference in New Issue
Block a user