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

Function TestSubsUpdate

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

Source from the content-addressed store, hash-verified

897}
898
899func TestSubsUpdate(t *testing.T) {
900 update := map[string]any{
901 "UpdatedAt": testData.Now.Add(22 * time.Minute),
902 }
903 err := adp.SubsUpdate(testData.Topics[0].Id, types.ParseUserId("usr"+testData.Users[0].Id), update)
904 if err != nil {
905 t.Fatal(err)
906 }
907 var got time.Time
908 err = db.QueryRow(ctx, "SELECT updatedat FROM subscriptions WHERE topic=$1 AND userid=$2",
909 testData.Topics[0].Id, decodeUid(testData.Users[0].Id)).Scan(&got)
910 if err != nil {
911 t.Fatal(err)
912 }
913 if got != update["UpdatedAt"] {
914 t.Error(mismatchErrorString("UpdatedAt", got, update["UpdatedAt"]))
915 }
916
917 err = adp.SubsUpdate(testData.Topics[1].Id, types.ZeroUid, update)
918 if err != nil {
919 t.Fatal(err)
920 }
921 err = db.QueryRow(ctx, "SELECT updatedat FROM subscriptions WHERE topic=$1 LIMIT 1",
922 testData.Topics[1].Id).Scan(&got)
923 if err != nil {
924 t.Fatal(err)
925 }
926 if got != update["UpdatedAt"] {
927 t.Error(mismatchErrorString("UpdatedAt", got, update["UpdatedAt"]))
928 }
929}
930
931func TestSubsDelete(t *testing.T) {
932 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
decodeUidFunction · 0.70
mismatchErrorStringFunction · 0.70
SubsUpdateMethod · 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…