3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/tests/home-assistant.nix

47 lines
1.1 KiB
Nix
Raw Normal View History

2018-01-26 00:41:36 +00:00
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";
latitude = "0.0";
longitude = "0.0";
elevation = 0;
2018-01-26 00:41:36 +00:00
};
frontend = { };
http = { };
};
};
};
};
2018-01-26 00:41:36 +00:00
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'");
$hass->fail("cat ${configDir}/home-assistant.log | grep -qF ERROR");
2018-01-26 00:41:36 +00:00
'';
})