initial commit from IBM Cloud example

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2019-06-03 10:42:48 +02:00
commit 4e76f510b3
Signed by: vbatts
GPG key ID: 10937E57733F1362
32 changed files with 1925 additions and 0 deletions

11
routers/health.go Normal file
View file

@ -0,0 +1,11 @@
package routers
import (
"github.com/gin-gonic/gin"
)
func HealthGET(c *gin.Context) {
c.JSON(200, gin.H{
"status": "UP",
})
}

28
routers/health_test.go Normal file
View file

@ -0,0 +1,28 @@
package routers
import (
"testing"
"net/http/httptest"
"net/http"
"github.com/gin-gonic/gin"
)
func TestHealth(t *testing.T) {
router := gin.Default()
router.GET("/health", HealthGET)
w := httptest.NewRecorder()
req := httptest.NewRequest("GET", "/health", nil)
router.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Fatalf("You received a %v error.", w.Code)
}
expected := "{\"status\":\"UP\"}"
actual := w.Body.String()
if actual != expected {
t.Errorf("Response should be %v, was %v.", expected, actual)
}
}