-
Notifications
You must be signed in to change notification settings - Fork 6
OCC-310: Fetch the log contents but only include the entries that will throw #466
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
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c273571
Prevent multiple enumeration.
sarahelsaig 3b7c5da
Add and use CachedApplicationLog.
sarahelsaig 6503608
Rename CachedApplicationLog to MemoryApplicationLog.
sarahelsaig e08aea8
bug fix
sarahelsaig 6310e07
comment
sarahelsaig d12610c
Remove unneeded CompatibilitySuppressions.xml
sarahelsaig f50b2d3
Merge remote-tracking branch 'origin/dev' into issue/OCC-310
sarahelsaig fabf280
Update CompatibilitySuppressions.
sarahelsaig c39a782
optimize LogsShouldNotContainAsync
sarahelsaig 46cb3a4
Clean up CreateAppLogAssertionForSecurityScan and handle inconsistent…
sarahelsaig 70d94c2
Add clarification in the comment.
sarahelsaig 61842e5
Merge remote-tracking branch 'origin/dev' into issue/OCC-310
Piedone 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
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,51 @@ | ||
| using Lombiq.Tests.UI.Services; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Lombiq.Tests.UI.Models; | ||
|
|
||
| /// <summary> | ||
| /// An <see cref="IApplicationLog"/> implementation where the entries are stored in memory. This makes the logs easier to inspect in IDE during | ||
| /// debugging and working with a list of this type is easier to filter and aggregate than the base type. | ||
| /// </summary> | ||
| public record MemoryApplicationLog(string Name, IList<IApplicationLogEntry> Entries) | ||
|
Piedone marked this conversation as resolved.
|
||
| : IApplicationLog | ||
| { | ||
| public int EntryCount => Entries.Count; | ||
|
|
||
| public Task<IEnumerable<IApplicationLogEntry>> GetEntriesAsync() => Task.FromResult(Entries.AsEnumerable()); | ||
| public Task RemoveAsync() => throw new NotSupportedException(); | ||
|
|
||
| /// <summary> | ||
| /// Converts an existing <paramref name="log"/> into in-memory log by eagerly fetching its contents. Use this to | ||
| /// avoid having to <see langword="await"/> <see cref="IApplicationLog.GetEntriesAsync"/> multiple times. | ||
| /// </summary> | ||
| public static Task<MemoryApplicationLog> FromLogAsync( | ||
| IApplicationLog log, | ||
| Func<IApplicationLogEntry, bool> predicate = null) | ||
| { | ||
| if (log.EntryCount < 1) | ||
| { | ||
| return Task.FromResult(new MemoryApplicationLog(log.Name, [])); | ||
| } | ||
|
|
||
| if (log is MemoryApplicationLog cached) | ||
| { | ||
| return Task.FromResult(new MemoryApplicationLog(log.Name, FilterEntries(cached.Entries, predicate))); | ||
| } | ||
|
|
||
| return FromLogInnerAsync(log, predicate); | ||
| } | ||
|
|
||
| private static async Task<MemoryApplicationLog> FromLogInnerAsync( | ||
| IApplicationLog log, | ||
| Func<IApplicationLogEntry, bool> predicate) => | ||
| new(log.Name, FilterEntries(await log.GetEntriesAsync(), predicate)); | ||
|
|
||
| private static IList<IApplicationLogEntry> FilterEntries( | ||
| IEnumerable<IApplicationLogEntry> entries, | ||
| Func<IApplicationLogEntry, bool> predicate) => | ||
| predicate is null ? entries.AsList() : entries.Where(predicate).ToList(); | ||
| } | ||
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.