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

Function TestUserUpdate

server/db/rethinkdb/tests/rethink_test.go:647–677  ·  view source on GitHub ↗

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

(t *testing.T)

Source from the content-addressed store, hash-verified

645
646// ================== Update tests ================================
647func TestUserUpdate(t *testing.T) {
648 update := map[string]any{
649 "UserAgent": "Test Agent v0.11",
650 "UpdatedAt": testData.Now.Add(30 * time.Minute),
651 }
652 err := adp.UserUpdate(types.ParseUserId("usr"+testData.Users[0].Id), update)
653 if err != nil {
654 t.Fatal(err)
655 }
656
657 cursor, err := rdb.Table("users").Get(testData.Users[0].Id).Pluck("UserAgent", "UpdatedAt", "CreatedAt").Run(conn)
658 if err != nil {
659 t.Fatal(err)
660 }
661 defer cursor.Close()
662
663 var got struct {
664 UserAgent string
665 UpdatedAt time.Time
666 CreatedAt time.Time
667 }
668 if err = cursor.One(&got); 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.Equal(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
mismatchErrorStringFunction · 0.70
UserUpdateMethod · 0.65
GetMethod · 0.65
CloseMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…