Blame


1 dd0af5f7 2022-01-18 o package icinga
2 dd0af5f7 2022-01-18 o
3 dd0af5f7 2022-01-18 o import (
4 562d5c1e 2022-01-19 o "os"
5 dd0af5f7 2022-01-18 o "testing"
6 dd0af5f7 2022-01-18 o )
7 dd0af5f7 2022-01-18 o
8 562d5c1e 2022-01-19 o func TestHostUnmarshal(t *testing.T) {
9 717a9e78 2022-02-02 o f, err := os.Open("testdata/objects/hosts/VuS9jZ8u.example.org")
10 562d5c1e 2022-01-19 o if err != nil {
11 562d5c1e 2022-01-19 o t.Fatal(err)
12 562d5c1e 2022-01-19 o }
13 562d5c1e 2022-01-19 o defer f.Close()
14 562d5c1e 2022-01-19 o resp, err := parseResponse(f)
15 562d5c1e 2022-01-19 o if err != nil {
16 562d5c1e 2022-01-19 o t.Fatal(err)
17 562d5c1e 2022-01-19 o }
18 cb667a50 2022-02-12 o host := resp.Results[0].(Host)
19 cb667a50 2022-02-12 o if host.LastCheck.IsZero() {
20 cb667a50 2022-02-12 o t.Error("zero time")
21 562d5c1e 2022-01-19 o }
22 cb667a50 2022-02-12 o if !host.Acknowledgement {
23 cb667a50 2022-02-12 o t.Error("should be acknowledged")
24 cb667a50 2022-02-12 o }
25 cb667a50 2022-02-12 o if t.Failed() {
26 cb667a50 2022-02-12 o t.Log(host)
27 cb667a50 2022-02-12 o }
28 562d5c1e 2022-01-19 o }