MCPcopy Index your code
hub / github.com/gotify/server / TestCollectConnectedClientTokens

Function TestCollectConnectedClientTokens

api/stream/stream_test.go:326–361  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

324}
325
326func TestCollectConnectedClientTokens(t *testing.T) {
327 mode.Set(mode.TestDev)
328
329 defer leaktest.Check(t)()
330 userIDs := []uint{1, 1, 1, 2, 2}
331 tokens := []string{"1-1", "1-2", "1-2", "2-1", "2-2"}
332 i := 0
333 server, api := bootTestServer(func(context *gin.Context) {
334 auth.RegisterAuthentication(context, nil, userIDs[i], tokens[i])
335 i++
336 })
337 defer server.Close()
338
339 wsURL := wsURL(server.URL)
340 userOneConnOne := testClient(t, wsURL)
341 defer userOneConnOne.conn.Close()
342 userOneConnTwo := testClient(t, wsURL)
343 defer userOneConnTwo.conn.Close()
344 userOneConnThree := testClient(t, wsURL)
345 defer userOneConnThree.conn.Close()
346 waitForConnectedClients(api, 3)
347
348 ret := api.CollectConnectedClientTokens()
349 sort.Strings(ret)
350 assert.Equal(t, []string{"1-1", "1-2"}, ret)
351
352 userTwoConnOne := testClient(t, wsURL)
353 defer userTwoConnOne.conn.Close()
354 userTwoConnTwo := testClient(t, wsURL)
355 defer userTwoConnTwo.conn.Close()
356 waitForConnectedClients(api, 5)
357
358 ret = api.CollectConnectedClientTokens()
359 sort.Strings(ret)
360 assert.Equal(t, []string{"1-1", "1-2", "2-1", "2-2"}, ret)
361}
362
363func TestMultipleClients(t *testing.T) {
364 mode.Set(mode.TestDev)

Callers

nothing calls this directly

Calls 9

SetFunction · 0.92
RegisterAuthenticationFunction · 0.92
bootTestServerFunction · 0.85
wsURLFunction · 0.85
testClientFunction · 0.85
waitForConnectedClientsFunction · 0.85
StringsMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…