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

Function TestTopicCreateP2P

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

Source from the content-addressed store, hash-verified

168}
169
170func TestTopicCreateP2P(t *testing.T) {
171 err := adp.TopicCreateP2P(testData.Subs[2], testData.Subs[3])
172 if err != nil {
173 t.Fatal(err)
174 }
175
176 oldModeGiven := testData.Subs[2].ModeGiven
177 testData.Subs[2].ModeGiven = 255
178 err = adp.TopicCreateP2P(testData.Subs[4], testData.Subs[2])
179 if err != nil {
180 t.Fatal(err)
181 }
182
183 var got types.Subscription
184 var userId int64
185 var modeWant, modeGiven []byte
186 err = db.QueryRow(ctx, "SELECT createdat,updatedat,deletedat,userid,topic,delid,recvseqid,readseqid,modewant,modegiven,private FROM subscriptions WHERE topic=$1 AND userid=$2",
187 testData.Subs[2].Topic, decodeUid(testData.Subs[2].User)).Scan(&got.CreatedAt,
188 &got.UpdatedAt, &got.DeletedAt, &userId, &got.Topic, &got.DelId, &got.RecvSeqId, &got.ReadSeqId,
189 &modeWant, &modeGiven, &got.Private)
190 if err != nil {
191 t.Fatal(err)
192 }
193 got.ModeGiven.Scan(modeGiven)
194 if got.ModeGiven == oldModeGiven {
195 t.Error("ModeGiven update failed")
196 }
197}
198
199func TestTopicShare(t *testing.T) {
200 if err := adp.TopicShare(testData.Subs[0].Topic, testData.Subs); err != nil {

Callers

nothing calls this directly

Calls 4

ErrorMethod · 0.80
decodeUidFunction · 0.70
TopicCreateP2PMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…