diff options
author | Linus Heckemann <git@sphalerite.org> | 2023-04-18 06:45:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 06:45:40 +0200 |
commit | b14aded48ae072caa50912ebf4dfce9d9b402fba (patch) | |
tree | 1c1ff67f8824acda3d4cc2c03a840ff4d20b79ee /nixos/tests | |
parent | 53b6e1a3c5ad2d42bd97f8a108bdb275954bf38b (diff) | |
parent | 8df62ec46c2871e8e2ae3dc0ac7954f91c0b30b6 (diff) |
Merge pull request #222617 from oddlama/esphome
nixos/esphome: init module
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/esphome.nix | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 061e41f7ed753..b45db283bd6f1 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -210,6 +210,7 @@ in { envoy = handleTest ./envoy.nix {}; ergo = handleTest ./ergo.nix {}; ergochat = handleTest ./ergochat.nix {}; + esphome = handleTest ./esphome.nix {}; etc = pkgs.callPackage ../modules/system/etc/test.nix { inherit evalMinimalConfig; }; activation = pkgs.callPackage ../modules/system/activation/test.nix { }; etcd = handleTestOn ["x86_64-linux"] ./etcd.nix {}; diff --git a/nixos/tests/esphome.nix b/nixos/tests/esphome.nix new file mode 100644 index 0000000000000..b8dbdb0b37957 --- /dev/null +++ b/nixos/tests/esphome.nix @@ -0,0 +1,41 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: + +let + testPort = 6052; + unixSocket = "/run/esphome/esphome.sock"; +in +with lib; +{ + name = "esphome"; + meta.maintainers = with pkgs.lib.maintainers; [ oddlama ]; + + nodes = { + esphomeTcp = { ... }: + { + services.esphome = { + enable = true; + port = testPort; + address = "0.0.0.0"; + openFirewall = true; + }; + }; + + esphomeUnix = { ... }: + { + services.esphome = { + enable = true; + enableUnixSocket = true; + }; + }; + }; + + testScript = '' + esphomeTcp.wait_for_unit("esphome.service") + esphomeTcp.wait_for_open_port(${toString testPort}) + esphomeTcp.succeed("curl --fail http://localhost:${toString testPort}/") + + esphomeUnix.wait_for_unit("esphome.service") + esphomeUnix.wait_for_file("${unixSocket}") + esphomeUnix.succeed("curl --fail --unix-socket ${unixSocket} http://localhost/") + ''; +}) |