Initial test for alert unmarshall

This commit is contained in:
Alex Ellis
2017-01-22 11:09:43 +00:00
parent ff429ce493
commit 158c412251
3 changed files with 34 additions and 0 deletions

View 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")
}
}