commit 62bf235cf08fdde3e89d389bdc78b8602069b28c
parent 87154adc3ffe738b0e1223d666c0ae63e1926399
Author: Oliver Lowe <o@olowe.co>
Date: Fri, 4 Feb 2022 14:23:43 +1100
icinga_test: Inline permissions response
No need for a file on disk; it's only referenced once.
Diffstat:
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/icinga_test.go b/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, req *http.Request) {
}
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, req *http.Request) {
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,
},
},