mirror of
https://github.com/pushbits/server.git
synced 2025-04-28 17:56:50 +02:00
31 lines
675 B
Go
31 lines
675 B
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/pushbits/server/tests"
|
|
)
|
|
|
|
func TestApi_Health(t *testing.T) {
|
|
ctx := GetTestContext(t)
|
|
|
|
assert := assert.New(t)
|
|
handler := HealthHandler{
|
|
DB: ctx.Database,
|
|
}
|
|
|
|
testCases := make([]tests.Request, 0)
|
|
testCases = append(testCases, tests.Request{Name: "-", Method: "GET", Endpoint: "/health", Data: "", ShouldStatus: 200})
|
|
|
|
for _, req := range testCases {
|
|
w, c, err := req.GetRequest()
|
|
if err != nil {
|
|
t.Fatal(err.Error())
|
|
}
|
|
handler.Health(c)
|
|
|
|
assert.Equalf(w.Code, req.ShouldStatus, "Health should result in status code %d but code is %d", req.ShouldStatus, w.Code)
|
|
}
|
|
}
|