summaryrefslogtreecommitdiff
path: root/internal/config/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config_test.go')
-rw-r--r--internal/config/config_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index 1a79320..521dd35 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -5,8 +5,10 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ "github.com/prometheus/client_golang/prometheus"
"gitlab.com/gitlab-org/gitlab-shell/internal/testhelper"
+ "gitlab.com/gitlab-org/gitlab-shell/client/testserver"
)
func TestConfigApplyGlobalState(t *testing.T) {
@@ -22,3 +24,27 @@ func TestConfigApplyGlobalState(t *testing.T) {
require.Equal(t, "foo", os.Getenv("SSL_CERT_DIR"))
}
+
+func TestHttpClient(t *testing.T) {
+ url := testserver.StartHttpServer(t, []testserver.TestRequestHandler{})
+
+ config := &Config{GitlabUrl: url}
+ client := config.HttpClient()
+
+ _, err := client.Get("http://host.com/path")
+ require.NoError(t, err)
+
+ ms, err := prometheus.DefaultGatherer.Gather()
+ require.NoError(t, err)
+
+ lastMetric := ms[0]
+ require.Equal(t, lastMetric.GetName(), "gitlab_shell_http_request_seconds")
+
+ labels := lastMetric.GetMetric()[0].Label
+
+ require.Equal(t, "code", labels[0].GetName())
+ require.Equal(t, "404", labels[0].GetValue())
+
+ require.Equal(t, "method", labels[1].GetName())
+ require.Equal(t, "get", labels[1].GetValue())
+}