mirror of
https://github.com/pushbits/server.git
synced 2025-06-06 12:41:59 +02:00
test for health
This commit is contained in:
parent
944e7da818
commit
c1631dd53e
1 changed files with 28 additions and 0 deletions
28
internal/api/health_test.go
Normal file
28
internal/api/health_test.go
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/pushbits/server/tests"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestApi_Health(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
handler := HealthHandler{
|
||||||
|
DB: TestDatabase,
|
||||||
|
}
|
||||||
|
|
||||||
|
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.Fatalf(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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue