test(api): remove health handler test file

This commit is contained in:
zenfun
2025-12-27 13:51:25 +08:00
parent 637bfa8210
commit f51cd63c82

View File

@@ -1,42 +0,0 @@
package api
import (
"fmt"
"net/http"
"net/http/httptest"
"testing"
"github.com/alicebob/miniredis/v2"
"github.com/ez-api/ez-api/internal/service"
"github.com/gin-gonic/gin"
"github.com/redis/go-redis/v9"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
func TestHealthHandler_TestDeps(t *testing.T) {
gin.SetMode(gin.TestMode)
dsn := fmt.Sprintf("file:%s?mode=memory&cache=shared", t.Name())
db, err := gorm.Open(sqlite.Open(dsn), &gorm.Config{})
if err != nil {
t.Fatalf("open sqlite: %v", err)
}
mr := miniredis.RunT(t)
rdb := redis.NewClient(&redis.Options{Addr: mr.Addr()})
svc := service.NewHealthCheckService(db, rdb)
h := NewHealthHandler(svc)
r := gin.New()
r.GET("/api/status/test", h.TestDeps)
req := httptest.NewRequest(http.MethodGet, "/api/status/test", nil)
rr := httptest.NewRecorder()
r.ServeHTTP(rr, req)
if rr.Code != http.StatusOK {
t.Fatalf("expected 200, got %d body=%s", rr.Code, rr.Body.String())
}
}