-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcharts_test.go
46 lines (42 loc) · 1.06 KB
/
charts_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/k8s-community/charts/version"
"github.com/takama/router"
)
func TestHealthHandler(t *testing.T) {
r := router.New()
r.GET("/healthz", healthz)
req, err := http.NewRequest("GET", "/healthz", nil)
if err != nil {
t.Error(err)
}
trw := httptest.NewRecorder()
r.ServeHTTP(trw, req)
if trw.Body.String() != "Ok" {
t.Error("Expected", "Ok", "got", trw.Body.String())
}
if trw.Code != 200 {
t.Error("Expected status:", 200, "got", trw.Body.String())
}
}
func TestInfoHandler(t *testing.T) {
r := router.New()
r.GET("/info", info)
req, err := http.NewRequest("GET", "/info", nil)
if err != nil {
t.Error(err)
}
trw := httptest.NewRecorder()
r.ServeHTTP(trw, req)
inf := "{\n \"commit\": \"" + version.COMMIT + "\",\n \"repo\": \"" + version.REPO +
"\",\n \"version\": \"" + version.RELEASE + "\"\n}"
if trw.Body.String() != inf {
t.Error("Expected", inf, "got", trw.Body.String())
}
if trw.Code != 200 {
t.Error("Expected status:", 200, "got", trw.Body.String())
}
}