mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
Cover low-coverage handler functions: handleGetPins, handleSetPinned, handleMetrics, handleDiagnosticsConnectivity, isPrivateIP, AdminIPRestrict, handleClientUpdate, and handleLiveKitHealth. Adds 30 new test cases across 4 new test files and 2 modified test files.
35 lines
951 B
Go
35 lines
951 B
Go
package api
|
|
|
|
import "net/http"
|
|
|
|
// HandleMetricsForTest exposes handleMetrics for use in external tests.
|
|
var HandleMetricsForTest = handleMetrics
|
|
|
|
// HandleLiveKitHealthForTest exposes handleLiveKitHealth for use in external tests.
|
|
func HandleLiveKitHealthForTest(healthCheck func() (bool, error)) http.HandlerFunc {
|
|
// Inline the logic since handleLiveKitHealth requires a *ws.Hub.
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
ok, err := healthCheck()
|
|
if ok {
|
|
writeJSON(w, http.StatusOK, livekitHealthResponse{
|
|
Status: "ok",
|
|
LiveKitReachable: true,
|
|
})
|
|
return
|
|
}
|
|
|
|
errMsg := "unknown"
|
|
if err != nil {
|
|
errMsg = err.Error()
|
|
}
|
|
writeJSON(w, http.StatusServiceUnavailable, livekitHealthResponse{
|
|
Status: "degraded",
|
|
LiveKitReachable: false,
|
|
Error: errMsg,
|
|
})
|
|
}
|
|
}
|
|
|
|
// IsPrivateIPForTest exposes isPrivateIP for use in external tests.
|
|
var IsPrivateIPForTest = isPrivateIP
|