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

Function TestSubsUpdate

server/db/rethinkdb/tests/rethink_test.go:928–970  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

926}
927
928func TestSubsUpdate(t *testing.T) {
929 update := map[string]any{
930 "UpdatedAt": testData.Now.Add(22 * time.Minute),
931 }
932 err := adp.SubsUpdate(testData.Topics[0].Id, types.ParseUserId("usr"+testData.Users[0].Id), update)
933 if err != nil {
934 t.Fatal(err)
935 }
936
937 cursor, err := rdb.Table("subscriptions").Get(testData.Topics[0].Id + ":" + testData.Users[0].Id).
938 Field("UpdatedAt").Run(conn)
939 if err != nil {
940 t.Fatal(err)
941 }
942 defer cursor.Close()
943
944 var got time.Time
945 if err = cursor.One(&got); err != nil {
946 t.Fatal(err)
947 }
948 if !got.Equal(update["UpdatedAt"].(time.Time)) {
949 t.Error(mismatchErrorString("UpdatedAt", got, update["UpdatedAt"]))
950 }
951
952 err = adp.SubsUpdate(testData.Topics[1].Id, types.ZeroUid, update)
953 if err != nil {
954 t.Fatal(err)
955 }
956
957 cursor2, err := rdb.Table("subscriptions").GetAllByIndex("Topic", testData.Topics[1].Id).
958 Field("UpdatedAt").Limit(1).Run(conn)
959 if err != nil {
960 t.Fatal(err)
961 }
962 defer cursor2.Close()
963
964 if err = cursor2.One(&got); err != nil {
965 t.Fatal(err)
966 }
967 if !got.Equal(update["UpdatedAt"].(time.Time)) {
968 t.Error(mismatchErrorString("UpdatedAt", got, update["UpdatedAt"]))
969 }
970}
971
972func TestSubsDelete(t *testing.T) {
973 err := adp.SubsDelete(testData.Topics[1].Id, types.ParseUserId("usr"+testData.Users[0].Id))

Callers

nothing calls this directly

Calls 7

ParseUserIdFunction · 0.92
ErrorMethod · 0.80
mismatchErrorStringFunction · 0.70
SubsUpdateMethod · 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…