-
Notifications
You must be signed in to change notification settings - Fork 0
feat(projections): expose event creation timestamp #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+131
−41
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dcd51c1
feat(projections): expose event creation timestamp
yordis 3e818b1
fix(projections): qualify event created timestamps
yordis 307396f
fix(tests): wait for replication subscription topology
yordis bb4018f
fix(tests): stabilize cluster restart convergence
yordis c405e24
fix(tests): extend arm cluster restart headroom
yordis 13c80fe
fix(tests): make cluster restart order deterministic
yordis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/EventStore.Projections.Core.Tests/Services/Jint/when_accessing_event_created_property.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| using System; | ||
| using System.Text; | ||
| using System.Text.Json; | ||
| using EventStore.Core.Data; | ||
| using NUnit.Framework; | ||
| using ResolvedEvent = EventStore.Projections.Core.Services.Processing.ResolvedEvent; | ||
|
|
||
| namespace EventStore.Projections.Core.Tests.Services.Jint; | ||
|
|
||
| [TestFixture(DateTimeKind.Utc)] | ||
| [TestFixture(DateTimeKind.Unspecified)] | ||
| public class when_accessing_event_created_property : specification_with_event_handled | ||
| { | ||
| private readonly DateTimeKind _timestampKind; | ||
|
|
||
| public when_accessing_event_created_property(DateTimeKind timestampKind) | ||
| { | ||
| _timestampKind = timestampKind; | ||
| } | ||
|
|
||
| private DateTime ExpectedTimestamp => new(2023, 4, 5, 12, 34, 56, _timestampKind); | ||
|
|
||
| protected override void Given() | ||
| { | ||
| _projection = @" | ||
| fromAll().when({$any: | ||
| function(state, event) { | ||
| return { created: event.created }; | ||
| } | ||
| }); | ||
| "; | ||
| _state = @"{}"; | ||
| _handledEvent = new ResolvedEvent( | ||
| positionStreamId: "test-stream", | ||
| positionSequenceNumber: 42, | ||
| eventStreamId: "test-stream", | ||
| eventSequenceNumber: 42, | ||
| resolvedLinkTo: false, | ||
| position: new TFPos(100, 50), | ||
| eventOrLinkTargetPosition: new TFPos(100, 50), | ||
| eventId: Guid.NewGuid(), | ||
| eventType: "TestEvent", | ||
| isJson: true, | ||
| data: Encoding.UTF8.GetBytes("{}"), | ||
| metadata: Encoding.UTF8.GetBytes("{}"), | ||
| positionMetadata: Array.Empty<byte>(), | ||
| streamMetadata: null, | ||
| timestamp: ExpectedTimestamp); | ||
| } | ||
|
|
||
| [Test, Category(_projectionType)] | ||
| public void exposes_the_event_timestamp_as_an_iso_8601_string() | ||
| { | ||
| using var state = JsonDocument.Parse(_newState); | ||
|
|
||
| var expectedTimestamp = DateTime.SpecifyKind(ExpectedTimestamp, DateTimeKind.Utc).ToString("o"); | ||
|
|
||
| Assert.That(state.RootElement.GetProperty("created").GetString(), Is.EqualTo(expectedTimestamp)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.