icinga

Icinga2 API client in Go
git clone https://git.olowe.co/icinga
Log | Files | Refs | README | LICENSE

host_test.go (459B)


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