diff --git a/gateway/requests/requests.go b/gateway/requests/requests.go index 94bfa8a3..fb40469c 100644 --- a/gateway/requests/requests.go +++ b/gateway/requests/requests.go @@ -21,3 +21,8 @@ type AlexaRequestBody struct { Session AlexaSession `json:"session"` Request AlexaRequest `json:"request"` } + +type PrometheusAlert struct { + Status string `json:"status"` + Receiver string `json:"receiver"` +} diff --git a/prometheus/test_alert.json b/gateway/tests/test_alert.json similarity index 100% rename from prometheus/test_alert.json rename to gateway/tests/test_alert.json diff --git a/gateway/tests/unmarshall_test.go b/gateway/tests/unmarshall_test.go new file mode 100644 index 00000000..989dcd33 --- /dev/null +++ b/gateway/tests/unmarshall_test.go @@ -0,0 +1,29 @@ +package requests + +import ( + "fmt" + "testing" + + "io/ioutil" + + "encoding/json" + + "github.com/alexellis/faas/gateway/requests" +) + +func TestUnmarshallAlert(t *testing.T) { + file, _ := ioutil.ReadFile("./test_alert.json") + + var alert requests.PrometheusAlert + err := json.Unmarshal(file, &alert) + if err != nil { + t.Fatal(err) + } + fmt.Println("OK", string(file), alert) + if (len(alert.Status)) == 0 { + t.Fatal("No status read") + } + if (len(alert.Receiver)) == 0 { + t.Fatal("No status read") + } +}