test(integration): update DB monitoring health assertion to match nested services payload
This commit is contained in:
@@ -2,7 +2,6 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -63,13 +62,33 @@ func TestIntegration_Router_FullMiddlewareChain(t *testing.T) {
|
|||||||
t.Run("DBMonitoring_Active", func(t *testing.T) {
|
t.Run("DBMonitoring_Active", func(t *testing.T) {
|
||||||
request := makeGetRequest(t, router, "/health")
|
request := makeGetRequest(t, router, "/health")
|
||||||
|
|
||||||
var response map[string]any
|
response := assertJSONResponse(t, request, http.StatusOK)
|
||||||
if err := json.NewDecoder(request.Body).Decode(&response); err == nil {
|
if response == nil {
|
||||||
if data, ok := response["data"].(map[string]any); ok {
|
return
|
||||||
if _, exists := data["database_stats"]; !exists {
|
|
||||||
t.Error("Expected database_stats in health response")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data, ok := getDataFromResponse(response)
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("Expected data to be a map")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
services, ok := data["services"].(map[string]any)
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("Expected services in health response")
|
||||||
|
}
|
||||||
|
|
||||||
|
databaseService, ok := services["database"].(map[string]any)
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("Expected database service in health response")
|
||||||
|
}
|
||||||
|
|
||||||
|
details, ok := databaseService["details"].(map[string]any)
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("Expected database details in health response")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, exists := details["stats"]; !exists {
|
||||||
|
t.Error("Expected database stats in health response")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user