prometheushandler_test.go 517 B

123456789101112131415161718192021
  1. package handler
  2. import (
  3. "net/http"
  4. "net/http/httptest"
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestPromMetricHandler(t *testing.T) {
  9. promMetricHandler := PromethousHandler("/user/login")
  10. handler := promMetricHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  11. w.WriteHeader(http.StatusOK)
  12. }))
  13. req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
  14. resp := httptest.NewRecorder()
  15. handler.ServeHTTP(resp, req)
  16. assert.Equal(t, http.StatusOK, resp.Code)
  17. }