ServiceReportTests looked at every delivery job of the last five minutes and read each body's actor. On the CI runner, slower than the workstation, other tests' jobs were still in that window, one of them without an actor, and four cases failed with a NullReferenceException. A test now sees only the jobs queued since it began, and checks the signer from the job itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
f105d1f7ea
commit
5ecf2d9629
1 file changed
+8
-6
@@ -30,6 +30,8 @@ namespace PrivaPub.Tests.Federation
|
||||
{
|
||||
static readonly string[] PeerHosts = { "localhost", "127.0.0.1" };
|
||||
|
||||
// (a test sees only the deliveries queued since it began: the others' share the database)
|
||||
readonly DateTime _started = DateTime.UtcNow;
|
||||
Harness _harness;
|
||||
|
||||
public async ValueTask InitializeAsync()
|
||||
@@ -74,10 +76,9 @@ namespace PrivaPub.Tests.Federation
|
||||
return post;
|
||||
}
|
||||
|
||||
async Task<List<(DeliveryPayload Payload, JsonObject Body)>> Queued() =>
|
||||
(await DB.Default.Find<Job>().Match(j => j.Kind == JobKind.Deliver && j.CreatedAt >= DateTime.UtcNow.AddMinutes(-5)).ExecuteAsync(Token))
|
||||
async Task<List<DeliveryPayload>> Queued() =>
|
||||
(await DB.Default.Find<Job>().Match(j => j.Kind == JobKind.Deliver && j.CreatedAt >= _started).ExecuteAsync(Token))
|
||||
.Select(j => JsonSerializer.Deserialize<DeliveryPayload>(j.Payload))
|
||||
.Select(p => (p, JsonNode.Parse(p.Body)!.AsObject()))
|
||||
.ToList();
|
||||
|
||||
// a community on a Lemmy, or on a server that takes reports as Lemmy does (the peer as localhost), and one of its posters there
|
||||
@@ -118,11 +119,12 @@ namespace PrivaPub.Tests.Federation
|
||||
Assert.Equal("a slur in the title", flag["summary"]!.GetValue<string>());
|
||||
Assert.Equal("a slur in the title", flag["content"]!.GetValue<string>());
|
||||
Assert.Empty(await _harness.Outgoing(poster.Id + "/inbox"));
|
||||
Assert.DoesNotContain(await Queued(), q => q.Payload.Inbox != community.SharedInbox && q.Body.ToJsonString().Contains(post.ObjectURI));
|
||||
Assert.DoesNotContain(await Queued(), q => q.Inbox != community.SharedInbox && q.Body.Contains(post.ObjectURI));
|
||||
Assert.DoesNotContain(alice.UserName, flag.ToJsonString());
|
||||
Assert.DoesNotContain(alice.Id, flag.ToJsonString());
|
||||
var queued = Assert.Single(await Queued(), q => q.Body["actor"]!.GetValue<string>() == reporter.Uri && q.Body["object"]!.GetValue<string>() == post.ObjectURI);
|
||||
Assert.Equal(LocalActorKind.Reporter, queued.Payload.SignerKind);
|
||||
var queued = Assert.Single(await Queued(), q => q.Inbox == community.SharedInbox);
|
||||
Assert.Equal(LocalActorKind.Reporter, queued.SignerKind);
|
||||
Assert.Equal(reporter.Id, queued.SignerId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in new issue
Block a user