1import ./make-test-python.nix ({ pkgs, lib, ... }: {
2 name = "goss";
3 meta.maintainers = [ lib.maintainers.anthonyroussel ];
4
5 nodes.machine = {
6 environment.systemPackages = [ pkgs.jq ];
7
8 services.goss = {
9 enable = true;
10
11 environment = {
12 GOSS_FMT = "json";
13 };
14
15 settings = {
16 addr."tcp://localhost:8080" = {
17 reachable = true;
18 local-address = "127.0.0.1";
19 };
20 command."check-goss-version" = {
21 exec = "${lib.getExe pkgs.goss} --version";
22 exit-status = 0;
23 };
24 dns.localhost.resolvable = true;
25 file."/nix" = {
26 filetype = "directory";
27 exists = true;
28 };
29 group.root.exists = true;
30 kernel-param."kernel.ostype".value = "Linux";
31 service.goss = {
32 enabled = true;
33 running = true;
34 };
35 user.root.exists = true;
36 };
37 };
38 };
39
40 testScript = ''
41 import json
42
43 machine.wait_for_unit("goss.service")
44 machine.wait_for_open_port(8080)
45
46 with subtest("returns health status"):
47 result = json.loads(machine.succeed("curl -sS http://localhost:8080/healthz"))
48
49 assert len(result["results"]) == 10, f".results should be an array of 10 items, was {result['results']!r}"
50 assert result["summary"]["failed-count"] == 0, f".summary.failed-count should be zero, was {result['summary']['failed-count']}"
51 assert result["summary"]["test-count"] == 10, f".summary.test-count should be 10, was {result['summary']['test-count']}"
52 '';
53})