mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 00:36:46 +00:00
40 lines
731 B
Go
40 lines
731 B
Go
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")
|
|
}
|
|
if (len(alert.Alerts)) == 0 {
|
|
t.Fatal("No alerts read")
|
|
}
|
|
if (len(alert.Alerts[0].Labels.AlertName)) == 0 {
|
|
t.Fatal("No alerts name")
|
|
}
|
|
if (len(alert.Alerts[0].Labels.FunctionName)) == 0 {
|
|
t.Fatal("No function name read")
|
|
}
|
|
|
|
}
|