forked from kubeflow/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhealthcheck__handler_test.go
More file actions
52 lines (40 loc) · 1.18 KB
/
healthcheck__handler_test.go
File metadata and controls
52 lines (40 loc) · 1.18 KB
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
47
48
49
50
51
52
package api
import (
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"testing"
"github.com/kubeflow/model-registry/ui/bff/internal/config"
"github.com/kubeflow/model-registry/ui/bff/internal/mocks"
"github.com/kubeflow/model-registry/ui/bff/internal/models"
"github.com/kubeflow/model-registry/ui/bff/internal/repositories"
"github.com/stretchr/testify/assert"
)
func TestHealthCheckHandler(t *testing.T) {
mockMRClient, _ := mocks.NewModelRegistryClient(nil)
app := App{config: config.EnvConfig{
Port: 4000,
},
repositories: repositories.NewRepositories(mockMRClient, mockModelCatalogClient),
}
rr := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, HealthCheckPath, nil)
assert.NoError(t, err)
app.HealthcheckHandler(rr, req, nil)
rs := rr.Result()
defer rs.Body.Close()
body, err := io.ReadAll(rs.Body)
assert.NoError(t, err)
var healthCheckRes models.HealthCheckModel
err = json.Unmarshal(body, &healthCheckRes)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, rr.Code)
expected := models.HealthCheckModel{
Status: "available",
SystemInfo: models.SystemInfo{
Version: Version,
},
}
assert.Equal(t, expected, healthCheckRes)
}