Skip to content

Commit

Permalink
Added tests for Event Type Filtering
Browse files Browse the repository at this point in the history
Cleaned up leftover in Nginx docker compose config
  • Loading branch information
oskardudycz committed May 24, 2024
1 parent 2fbf052 commit 83034ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Xunit;

namespace Core.EventStoreDB.Tests.Subscriptions.Filtering;

using static EventFilters;

public class EventTypeFiltersTests
Expand All @@ -14,7 +15,8 @@ public void ExcludeSystemAndCheckpointEventsRegex_Should_NotMatch_SystemEvents()
{
ExcludeSystemAndCheckpointEventsRegex.IsMatch("$scavengeIndexInitialized").Should().BeFalse();
ExcludeSystemAndCheckpointEventsRegex.IsMatch(typeof(CheckpointStored).FullName!).Should().BeFalse();
ExcludeSystemAndCheckpointEventsRegex.IsMatch("Core.EventStoreDB.Subscriptions.Checkpoints.CheckpointStored").Should().BeFalse();
ExcludeSystemAndCheckpointEventsRegex.IsMatch("Core.EventStoreDB.Subscriptions.Checkpoints.CheckpointStored")
.Should().BeFalse();
}

[Fact]
Expand Down Expand Up @@ -53,6 +55,17 @@ public void OneOfEventTypesRegex_WithEventTypeMapper_Should_Match_ProvidedEventT
regex.IsMatch("ShoppingCartOpened").Should().BeTrue();
}

[Fact]
public void OneOfEventTypesRegex_WithEventTypeMapper_Should_NotMatch_EventTypesWithDefaultName()
{
var eventTypeMapper = new EventTypeMapper();
eventTypeMapper.AddCustomMap<ShoppingCartOpened>("ShoppingCartOpened");

var regex = OneOfEventTypesRegex(eventTypeMapper, typeof(ShoppingCartOpened));

regex.IsMatch(typeof(ShoppingCartOpened).FullName!).Should().BeFalse();
}

[Fact]
public void OneOfEventTypesRegex_WithEventTypeMapper_Should_NotMatch_OtherEventTypesWithCustomMap()
{
Expand All @@ -62,8 +75,10 @@ public void OneOfEventTypesRegex_WithEventTypeMapper_Should_NotMatch_OtherEventT
var regex = OneOfEventTypesRegex(eventTypeMapper, typeof(ShoppingCartOpened));

regex.IsMatch("OrderPlaced").Should().BeFalse();
regex.IsMatch(typeof(ShoppingCartOpened).FullName!).Should().BeFalse();
regex.IsMatch(typeof(OrderPlaced).FullName!).Should().BeFalse();
}

[Fact]
public void OneOfEventTypesRegex_WithEventTypeMapper_Should_Match_ProvidedEventTypes()
{
Expand All @@ -82,10 +97,16 @@ public void OneOfEventTypesRegex_WithEventTypeMapper_Should_NotMatch_OtherEventT
var regex = OneOfEventTypesRegex(eventTypeMapper, typeof(ShoppingCartOpened));

regex.IsMatch("OrderPlaced").Should().BeFalse();
regex.IsMatch(typeof(OrderPlaced).FullName!).Should().BeFalse();
}

private record ShoppingCartOpened(
Guid ShoppingCartId,
Guid ClientId
);

private record OrderPlaced(
Guid OrderId,
Guid ClientId
);
}
1 change: 0 additions & 1 deletion Sample/Helpdesk/Helpdesk.Api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ services:
- 8089:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
# - ./nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- backend

Expand Down

0 comments on commit 83034ed

Please sign in to comment.