MCPcopy Create free account
hub / github.com/asternic/wuzapi / TestSessionStatus

Function TestSessionStatus

stdio_test.go:197–238  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

195}
196
197func TestSessionStatus(t *testing.T) {
198 s := makeTestServer(t)
199
200 // First create a user to get a valid token
201 addRequest := newRequest("1", "admin.users.add", map[string]interface{}{
202 "adminToken": "test-admin-token",
203 "name": "TestUser",
204 "token": "test-user-token",
205 }).toJSON(t)
206 addResponse := executeRequest(t, s, addRequest)
207
208 expectedAdd := map[string]interface{}{
209 "jsonrpc": "2.0",
210 "id": "1",
211 }
212 if diff := compareJSON(expectedAdd, addResponse); diff != "" {
213 t.Errorf("Add response mismatch:\n%s", diff)
214 }
215
216 // Now check session status
217 statusRequest := newRequest("2", "session.status", map[string]interface{}{
218 "token": "test-user-token",
219 }).toJSON(t)
220 statusResponse := executeRequest(t, s, statusRequest)
221
222 expectedStatus := map[string]interface{}{
223 "jsonrpc": "2.0",
224 "id": "2",
225 }
226 if diff := compareJSON(expectedStatus, statusResponse); diff != "" {
227 t.Errorf("Status response mismatch:\n%s", diff)
228 }
229
230 // Verify response has expected fields
231 data := statusResponse["result"].(map[string]interface{})
232 if _, hasConnected := data["connected"]; !hasConnected {
233 t.Errorf("Status response missing 'connected' field")
234 }
235 if _, hasLoggedIn := data["loggedIn"]; !hasLoggedIn {
236 t.Errorf("Status response missing 'loggedIn' field")
237 }
238}
239
240// Note: session.connect, session.disconnect, session.logout tests are skipped
241// because they require full WhatsApp/whatsmeow initialization which is complex

Callers

nothing calls this directly

Calls 5

makeTestServerFunction · 0.85
newRequestFunction · 0.85
executeRequestFunction · 0.85
compareJSONFunction · 0.85
toJSONMethod · 0.80

Tested by

no test coverage detected