Skip to content

Commit

Permalink
#3634 Livestream aggregations break on multi-tenancy
Browse files Browse the repository at this point in the history
  • Loading branch information
erdtsieck authored and jeremydmiller committed Jan 24, 2025
1 parent 27e5e34 commit d0b43b7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/DaemonTests/event_projection_scenario_tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ await theStore.Advanced.EventProjectionScenario(scenario =>
});
}

[Fact]
public async Task happy_path_test_with_live_projection_multi_tenanted()
{
StoreOptions(opts =>
{
opts.Projections.LiveStreamAggregation<LiveUser>();
opts.Events.TenancyStyle = TenancyStyle.Conjoined;
});

await theStore.Advanced.Clean.DeleteAllEventDataAsync();
var id = Guid.NewGuid();

await theStore.Advanced.EventProjectionScenario(scenario =>
{
scenario.Append(Guid.NewGuid(), new CreateUser { UserId = id, UserName = "Kareem" });
scenario.DocumentShouldNotExist<User>(id);
});

var user = await theSession.Events.AggregateStreamAsync<LiveUser>(id);
user.ShouldNotBeNull();
user.UserName.ShouldBe("Kareem");
}

[Fact]
public async Task sad_path_test_with_inline_projection()
{
Expand Down Expand Up @@ -279,3 +302,18 @@ public void Project(DeleteUser deletion, IDocumentOperations operations)
}

#endregion

public class LiveUser
{
public Guid Id { get; set; }
public string UserName { get; set; }

public LiveUser Create(CreateUser create)
{
return new LiveUser
{
Id = create.UserId,
UserName = create.UserName
};
}
}

0 comments on commit d0b43b7

Please sign in to comment.