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

Function TestCredFail

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

Source from the content-addressed store, hash-verified

733}
734
735func TestCredFail(t *testing.T) {
736 err := adp.CredFail(types.ParseUserId("usr"+testData.Creds[3].User), "tel")
737 if err != nil {
738 t.Error(err)
739 }
740
741 // Check if fields updated
742 var got struct {
743 Retries int
744 UpdatedAt time.Time
745 CreatedAt time.Time
746 }
747 err = db.QueryRow(ctx, "SELECT retries, updatedat, createdat FROM credentials WHERE userid=$1 AND method=$2 AND value=$3",
748 decodeUid(testData.Creds[3].User), "tel", testData.Creds[3].Value).Scan(&got.Retries, &got.UpdatedAt, &got.CreatedAt)
749 if err != nil {
750 t.Fatal(err)
751 }
752 if got.Retries != 1 {
753 t.Error(mismatchErrorString("Retries count", got.Retries, 1))
754 }
755 if got.UpdatedAt == got.CreatedAt {
756 t.Error("UpdatedAt field not updated")
757 }
758}
759
760func TestCredConfirm(t *testing.T) {
761 err := adp.CredConfirm(types.ParseUserId("usr"+testData.Creds[3].User), "tel")

Callers

nothing calls this directly

Calls 6

ParseUserIdFunction · 0.92
ErrorMethod · 0.80
decodeUidFunction · 0.70
mismatchErrorStringFunction · 0.70
CredFailMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…