MCPcopy Create free account
hub / github.com/astercloud/aster / TestWebBridgeHealthCheck

Function TestWebBridgeHealthCheck

pkg/desktop/desktop_test.go:69–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestWebBridgeHealthCheck(t *testing.T) {
70 app, err := NewApp(&AppConfig{
71 Framework: FrameworkWeb,
72 Port: 0, // Will use default
73 })
74 if err != nil {
75 t.Fatalf("NewApp() error = %v", err)
76 }
77
78 bridge := app.Bridge().(*WebBridge)
79
80 // Create test request
81 req := httptest.NewRequest(http.MethodGet, "/health", nil)
82 rec := httptest.NewRecorder()
83
84 // Create a handler that includes health check
85 mux := http.NewServeMux()
86 mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
87 _ = json.NewEncoder(w).Encode(map[string]any{
88 "status": "ok",
89 "framework": bridge.Framework(),
90 })
91 })
92
93 mux.ServeHTTP(rec, req)
94
95 if rec.Code != http.StatusOK {
96 t.Errorf("Status code = %d, want %d", rec.Code, http.StatusOK)
97 }
98
99 var resp map[string]any
100 if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
101 t.Fatalf("Failed to unmarshal response: %v", err)
102 }
103
104 if resp["status"] != "ok" {
105 t.Errorf("status = %v, want ok", resp["status"])
106 }
107}
108
109func TestMessageTypes(t *testing.T) {
110 tests := []struct {

Callers

nothing calls this directly

Calls 4

BridgeMethod · 0.95
NewAppFunction · 0.85
FrameworkMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected