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

Function TestUserUpdate

server/db/postgres/tests/postgres_test.go:651–677  ·  view source on GitHub ↗

================== Update tests ================================

(t *testing.T)

Source from the content-addressed store, hash-verified

649
650// ================== Update tests ================================
651func TestUserUpdate(t *testing.T) {
652 update := map[string]any{
653 "UserAgent": "Test Agent v0.11",
654 "UpdatedAt": testData.Now.Add(30 * time.Minute),
655 }
656 err := adp.UserUpdate(types.ParseUserId("usr"+testData.Users[0].Id), update)
657 if err != nil {
658 t.Fatal(err)
659 }
660
661 var got struct {
662 UserAgent string
663 UpdatedAt time.Time
664 CreatedAt time.Time
665 }
666 err = db.QueryRow(ctx, "SELECT useragent, updatedat, createdat FROM users WHERE id=$1",
667 decodeUid(testData.Users[0].Id)).Scan(&got.UserAgent, &got.UpdatedAt, &got.CreatedAt)
668 if err != nil {
669 t.Fatal(err)
670 }
671 if got.UserAgent != "Test Agent v0.11" {
672 t.Error(mismatchErrorString("UserAgent", got.UserAgent, "Test Agent v0.11"))
673 }
674 if got.UpdatedAt == got.CreatedAt {
675 t.Error("UpdatedAt field not updated")
676 }
677}
678
679func TestUserUpdateTags(t *testing.T) {
680 addTags := testData.Tags[0]

Callers

nothing calls this directly

Calls 7

ParseUserIdFunction · 0.92
ErrorMethod · 0.80
decodeUidFunction · 0.70
mismatchErrorStringFunction · 0.70
UserUpdateMethod · 0.65
AddMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…