mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 14:23:25 +00:00
Initial test for alert unmarshall
This commit is contained in:
@ -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"`
|
||||
}
|
||||
|
29
gateway/tests/unmarshall_test.go
Normal file
29
gateway/tests/unmarshall_test.go
Normal file
@ -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")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user