mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-20 22:08:50 +00:00
Add forwarding, friend controls, and benefits
Add message forwarding and reply lookup, friend removal and blocking endpoints, and database-backed Govor+ privileges with customizable profile tags. Include migrations, integration tests, and updated API and operations documentation.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using Govor.Application.Friends;
|
||||
using Govor.Domain.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Govor.Application.Tests.Integration.Friends;
|
||||
|
||||
[TestFixture]
|
||||
public sealed class FriendRemovalTests
|
||||
{
|
||||
[TestCase(FriendshipStatus.Pending)]
|
||||
[TestCase(FriendshipStatus.Blocked)]
|
||||
[TestCase(FriendshipStatus.Rejected)]
|
||||
[TestCase(FriendshipStatus.Accepted)]
|
||||
public async Task RemovalChangesOnlyAcceptedFriendshipAndRetainsHistory(FriendshipStatus status)
|
||||
{
|
||||
using var db = new TestDatabase();
|
||||
db.Context.Friendships.Add(new Friendship { Id = Guid.NewGuid(), RequesterId = db.Alice, AddresseeId = db.Bob, Status = status });
|
||||
await db.Context.SaveChangesAsync();
|
||||
var message = db.AddMessage();
|
||||
var service = new FriendshipService(db.Context);
|
||||
await service.RemoveFriendAsync(db.Bob, db.Alice);
|
||||
await service.RemoveFriendAsync(db.Alice, db.Bob);
|
||||
Assert.That((await db.Context.Friendships.AsNoTracking().SingleAsync()).Status,
|
||||
Is.EqualTo(status == FriendshipStatus.Accepted ? FriendshipStatus.Rejected : status));
|
||||
Assert.That(await db.Context.Messages.AnyAsync(m => m.Id == message.Id), Is.True);
|
||||
Assert.That(await db.Context.PrivateChats.AnyAsync(c => c.Id == db.ChatId), Is.True);
|
||||
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(db.Alice, db.Alice));
|
||||
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(Guid.Empty, db.Alice));
|
||||
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(db.Alice, Guid.Empty));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user