Commit Diff


commit - e0c24850440b8bcaa5bf6a49c0dd493fb30e94fb
commit + 5105405ecc4e2ca95d7a7bab841b3de1520fc852
blob - d52a46c819fca3af7e1bcce94a5aaeb5c96fddf5
blob + 0941ccaf77ba1a415287d5a0b40228f9594e1d8b
--- crud.go
+++ crud.go
@@ -207,4 +207,3 @@ func (c *Client) DeleteHostGroup(name string) error {
 	}
 	return nil
 }
-
blob - 289f59e1aac4805abaa01e56213a8b612e2121a5
blob + 0ba8c204eb380a63e77bd017dfdc13ea4ee6ab83
--- host.go
+++ host.go
@@ -15,7 +15,7 @@ type Host struct {
 }
 
 type HostGroup struct {
-	Name string `json:"name"`
+	Name        string `json:"name"`
 	DisplayName string `json:"display_name"`
 }
 
@@ -76,7 +76,7 @@ func (h Host) MarshalJSON() ([]byte, error) {
 
 func (hg HostGroup) MarshalJSON() ([]byte, error) {
 	type attrs struct {
-		DisplayName  string `json:"display_name"`
+		DisplayName string `json:"display_name"`
 	}
 	type group struct {
 		Attrs attrs `json:"attrs"`
blob - fbeaba13612776537813dbc19a3a467fc0b5eb46
blob + cfb416dc03d1d61daf3291217af43e419123563b
--- host_test.go
+++ host_test.go
@@ -1,10 +1,8 @@
 package icinga
 
 import (
-	"crypto/tls"
 	"errors"
 	"math/rand"
-	"net/http"
 	"sort"
 	"testing"
 )
@@ -31,11 +29,7 @@ func compareStringSlice(a, b []string) bool {
 }
 
 func TestFilter(t *testing.T) {
-	tp := http.DefaultTransport.(*http.Transport)
-	tp.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
-	c := http.DefaultClient
-	c.Transport = tp
-	client, err := Dial("127.0.0.1:5665", "root", "icinga", c)
+	client, err := newTestClient()
 	if err != nil {
 		t.Skipf("no local test icinga? got: %v", err)
 	}
@@ -53,9 +47,9 @@ func TestFilter(t *testing.T) {
 	var want, got []string
 	for i := 0; i < 5; i++ {
 		h := Host{
-			Name: randomHostname(),
-			CheckCommand: "hostalive", 
-			Groups: []string{hostgroup.Name},
+			Name:         randomHostname(),
+			CheckCommand: "hostalive",
+			Groups:       []string{hostgroup.Name},
 		}
 		want = append(want, h.Name)
 		if err := client.CreateHost(h); err != nil {
@@ -72,7 +66,7 @@ func TestFilter(t *testing.T) {
 				t.Log(err)
 			}
 		}
-	}()			
+	}()
 	hosts, err := client.Hosts("match(\"*example.org\", host.name)")
 	if err != nil {
 		t.Fatal(err)
blob - 372e7fbb5684e35d88de02751942c1b681b40492
blob + f6c54ed27fec491ddd88b23d317b3dab0177b880
--- user_test.go
+++ user_test.go
@@ -10,6 +10,14 @@ import (
 	"testing"
 )
 
+func newTestClient() (*Client, error) {
+	tp := http.DefaultTransport.(*http.Transport)
+	tp.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
+	c := http.DefaultClient
+	c.Transport = tp
+	return Dial("127.0.0.1:5665", "root", "icinga", c)
+}
+
 func TestUser(t *testing.T) {
 	want := User{Name: "test", Email: "test@example.com", Groups: []string{}}
 	f, err := os.Open("testdata/users.json")
@@ -48,15 +56,10 @@ func TestUserMarshal(t *testing.T) {
 }
 
 func TestUserRoundTrip(t *testing.T) {
-	tp := http.DefaultTransport.(*http.Transport)
-	tp.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
-	c := http.DefaultClient
-	c.Transport = tp
-	client, err := Dial("127.0.0.1:5665", "root", "icinga", c)
+	client, err := newTestClient()
 	if err != nil {
 		t.Skipf("no local test icinga? got: %v", err)
 	}
-
 	want := User{Name: "olly", Email: "olly@example.com", Groups: []string{}}
 	if err := client.CreateUser(want); err != nil && !errors.Is(err, ErrExist) {
 		t.Fatal(err)