test(shangwutong): cover CID rename reliability (#7)
Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -31,6 +31,21 @@ func TestContactUpdateQueuesDurableShangwutongEvent(t *testing.T) {
|
||||
require.Equal(t, contact.ID, event.ContactID)
|
||||
}
|
||||
|
||||
func TestContactUpdateRollsBackWhenDurableEventCannotBeQueued(t *testing.T) {
|
||||
db := setupServiceTestDB(t)
|
||||
account := createTestAccount(t, db)
|
||||
contact := &model.Contact{AccountID: account.ID, Name: "旧昵称"}
|
||||
require.NoError(t, db.Create(contact).Error)
|
||||
svc := NewContactService(repository.NewContactRepo(db), nil, repository.NewNoteRepo(db))
|
||||
svc.SetWorkerPool(worker.NewWorkerPool(db))
|
||||
require.NoError(t, db.Migrator().DropTable(&model.BackgroundJob{}))
|
||||
|
||||
_, err := svc.Update(context.Background(), account.ID, contact.ID, UpdateContactRequest{Name: "新昵称"})
|
||||
require.Error(t, err)
|
||||
require.NoError(t, db.First(contact, contact.ID).Error)
|
||||
require.Equal(t, "旧昵称", contact.Name)
|
||||
}
|
||||
|
||||
func TestShangwutongContactListenerQueuesOnlyCIDBoundInboxes(t *testing.T) {
|
||||
db := setupServiceTestDB(t)
|
||||
account := createTestAccount(t, db)
|
||||
|
||||
Reference in New Issue
Block a user