commit 62bf235cf08fdde3e89d389bdc78b8602069b28c from: Oliver Lowe date: Fri Feb 04 03:23:43 2022 UTC icinga_test: Inline permissions response No need for a file on disk; it's only referenced once. commit - 87154adc3ffe738b0e1223d666c0ae63e1926399 commit + 62bf235cf08fdde3e89d389bdc78b8602069b28c blob - 1f48b98148f9c7834c9e516cdfa9238b4c297c99 blob + 0efdde60577820a6358e4b75bb865e043efa2199 --- icinga_test.go +++ icinga_test.go @@ -5,11 +5,9 @@ import ( "encoding/json" "errors" "fmt" - "io" "math/rand" "net/http" "net/http/httptest" - "os" "path" "reflect" "sort" @@ -239,12 +237,13 @@ func (srv *fakeServer) ServeHTTP(w http.ResponseWriter } func (f *fakeServer) Permissions(w http.ResponseWriter) { - file, err := os.Open("testdata/permissions.json") - if err != nil { - panic(err) - } - defer file.Close() - io.Copy(w, file) + fmt.Fprint(w, `{"results": [{ + "info": "Fake Icinga2 server", + "permissions": ["*"], + "user": "icinga", + "version": "fake" + }]}`) + } type apiResponse struct { @@ -253,8 +252,8 @@ type apiResponse struct { } type apiResult struct { - Name string `json:"name"` - Type string `json:"type"` + Name string `json:"name"` + Type string `json:"type"` Attrs attributes `json:"attrs"` } @@ -307,8 +306,8 @@ func (srv *fakeServer) GetObject(w http.ResponseWriter resp := apiResponse{ Results: []apiResult{ apiResult{ - Name: path.Base(req.URL.Path), - Type: objType(req.URL.Path), + Name: path.Base(req.URL.Path), + Type: objType(req.URL.Path), Attrs: attrs, }, },