From 0604c078a8a61faaf179908551dc6ffe82f75b8b Mon Sep 17 00:00:00 2001 From: Robert Schütz Date: Fri, 26 Jan 2018 01:41:36 +0100 Subject: home-assistant: add NixOS test --- nixos/release.nix | 1 + nixos/tests/home-assistant.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 nixos/tests/home-assistant.nix (limited to 'nixos') diff --git a/nixos/release.nix b/nixos/release.nix index 972c89c1a411..a396eaac9a3e 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -267,6 +267,7 @@ in rec { tests.graphite = callTest tests/graphite.nix {}; tests.hardened = callTest tests/hardened.nix { }; tests.hibernate = callTest tests/hibernate.nix {}; + tests.home-assistant = callTest tests/home-assistant.nix { }; tests.hound = callTest tests/hound.nix {}; tests.i3wm = callTest tests/i3wm.nix {}; tests.initrd-network-ssh = callTest tests/initrd-network-ssh {}; diff --git a/nixos/tests/home-assistant.nix b/nixos/tests/home-assistant.nix new file mode 100644 index 000000000000..0e2fee8e808d --- /dev/null +++ b/nixos/tests/home-assistant.nix @@ -0,0 +1,41 @@ +import ./make-test.nix ({ pkgs, ... }: + +let + configDir = "/var/lib/foobar"; + +in { + name = "home-assistant"; + + nodes = { + hass = + { config, pkgs, ... }: + { + services.home-assistant = { + inherit configDir; + enable = true; + config = { + homeassistant = { + name = "Home"; + time_zone = "UTC"; + }; + frontend = { }; + http = { }; + }; + }; + }; + }; + + testScript = '' + startAll; + $hass->waitForUnit("home-assistant.service"); + + # Since config is specified using a Nix attribute set, + # configuration.yaml is a link to the Nix store + $hass->succeed("test -L ${configDir}/configuration.yaml"); + + # Check that Home Assistant's web interface and API can be reached + $hass->waitForOpenPort(8123); + $hass->succeed("curl --fail http://localhost:8123/states"); + $hass->succeed("curl --fail http://localhost:8123/api/ | grep 'API running'"); + ''; +}) -- cgit 1.4.1