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