MCPcopy
hub / github.com/tinode/chat / TestTopicsForUser

Function TestTopicsForUser

server/db/postgres/tests/postgres_test.go:428–468  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

426}
427
428func TestTopicsForUser(t *testing.T) {
429 qOpts := types.QueryOpt{
430 Topic: "p2p9AVDamaNCRbfKzGSh3mE0w",
431 Limit: 999,
432 }
433 gotSubs, err := adp.TopicsForUser(types.ParseUserId("usr"+testData.Users[0].Id), false, &qOpts)
434 if err != nil {
435 t.Fatal(err)
436 }
437 if len(gotSubs) != 1 {
438 t.Error(mismatchErrorString("Subs length", len(gotSubs), 1))
439 }
440
441 gotSubs, err = adp.TopicsForUser(types.ParseUserId("usr"+testData.Users[1].Id), true, nil)
442 if err != nil {
443 t.Fatal(err)
444 }
445 if len(gotSubs) != 2 {
446 t.Error(mismatchErrorString("Subs length (2)", len(gotSubs), 2))
447 }
448
449 qOpts.Topic = ""
450 ims := testData.Now.Add(15 * time.Minute)
451 qOpts.IfModifiedSince = &ims
452 gotSubs, err = adp.TopicsForUser(types.ParseUserId("usr"+testData.Users[0].Id), false, &qOpts)
453 if err != nil {
454 t.Fatal(err)
455 }
456 if len(gotSubs) != 1 {
457 t.Error(mismatchErrorString("Subs length (IMS)", len(gotSubs), 1))
458 }
459
460 ims = time.Now().Add(15 * time.Minute)
461 gotSubs, err = adp.TopicsForUser(types.ParseUserId("usr"+testData.Users[0].Id), false, &qOpts)
462 if err != nil {
463 t.Fatal(err)
464 }
465 if len(gotSubs) != 0 {
466 t.Error(mismatchErrorString("Subs length (IMS 2)", len(gotSubs), 0))
467 }
468}
469
470func TestUsersForTopic(t *testing.T) {
471 qOpts := types.QueryOpt{

Callers

nothing calls this directly

Calls 5

ParseUserIdFunction · 0.92
ErrorMethod · 0.80
mismatchErrorStringFunction · 0.70
TopicsForUserMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…