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
|
package healthcheck
import (
"context"
"encoding/json"
"net/http"
"testing"
"gitlab.com/gitlab-org/gitlab-shell/v14/client/testserver"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/config"
"github.com/stretchr/testify/require"
)
var (
requests = []testserver.TestRequestHandler{
{
Path: "/api/v4/internal/check",
Handler: func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(testResponse)
},
},
}
testResponse = &Response{
APIVersion: "v4",
GitlabVersion: "v12.0.0-ee",
GitlabRevision: "3b13818e8330f68625d80d9bf5d8049c41fbe197",
Redis: true,
}
)
func TestCheck(t *testing.T) {
client := setup(t)
result, err := client.Check(context.Background())
require.NoError(t, err)
require.Equal(t, testResponse, result)
}
func setup(t *testing.T) *Client {
url := testserver.StartSocketHttpServer(t, requests)
client, err := NewClient(&config.Config{GitlabUrl: url})
require.NoError(t, err)
return client
}
|