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

Function TestDeviceDelete

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

Source from the content-addressed store, hash-verified

1043}
1044
1045func TestDeviceDelete(t *testing.T) {
1046 err := adp.DeviceDelete(types.ParseUserId("usr"+testData.Users[1].Id), testData.Devs[0].DeviceId)
1047 if err != nil {
1048 t.Fatal(err)
1049 }
1050 var count int
1051 err = db.QueryRow(ctx, "SELECT COUNT(*) FROM devices WHERE userid=$1 AND deviceid=$2",
1052 decodeUid(testData.Users[1].Id), testData.Devs[0].DeviceId).Scan(&count)
1053 if err != nil {
1054 t.Fatal(err)
1055 }
1056 if count != 0 {
1057 t.Error("Device not deleted:", count)
1058 }
1059
1060 err = adp.DeviceDelete(types.ParseUserId("usr"+testData.Users[2].Id), "")
1061 if err != nil {
1062 t.Fatal(err)
1063 }
1064 err = db.QueryRow(ctx, "SELECT COUNT(*) FROM devices WHERE userid=$1",
1065 decodeUid(testData.Users[2].Id)).Scan(&count)
1066 if err != nil {
1067 t.Fatal(err)
1068 }
1069 if count != 0 {
1070 t.Error("All devices not deleted:", count)
1071 }
1072}
1073
1074// ================== Persistent Cache tests ======================
1075func TestPCacheUpsert(t *testing.T) {

Callers

nothing calls this directly

Calls 5

ParseUserIdFunction · 0.92
ErrorMethod · 0.80
decodeUidFunction · 0.70
DeviceDeleteMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…