Skip to content
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

Test refactorings #208

Merged
merged 7 commits into from
Feb 12, 2025
Merged

Test refactorings #208

merged 7 commits into from
Feb 12, 2025

Conversation

nulltoken
Copy link
Collaborator

@nulltoken nulltoken commented Feb 11, 2025

Pull request description

  • Move test helpers in a subdirectory
  • Introduce various helper methods to make it easier to work with event based assertions.

PR meta checklist

  • Pull request is targeted at main branch for code
  • Pull request is linked to all related issues, if any.

Code PR specific checklist

  • My code follows the code style of this project and AspNetCore coding guidelines.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I have updated the appropriate sub section in the CHANGELOG.md.
  • I have added, updated or removed tests to according to my changes.
    • All tests passed.

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

see 2 files with indirect coverage changes

@nulltoken nulltoken requested a review from linkdotnet February 11, 2025 21:14
@nulltoken
Copy link
Collaborator Author

Weirdo...

image

Looks unrelated to my changes as far as I can tell. Previous builds on this PR pass without any hiccup. I'll blame this on a GitHub transient issue and will give it another try tomorrow....

@nulltoken nulltoken force-pushed the ntk/events_helper branch 2 times, most recently from 230819d to e42e3f5 Compare February 11, 2025 22:32
@nulltoken
Copy link
Collaborator Author

Weirdo...

image

Looks unrelated to my changes as far as I can tell. Previous builds on this PR pass without any hiccup. I'll blame this on a GitHub transient issue and will give it another try tomorrow....

Ok. For (some) reason, .NET SDK now doesn't detect anymore the .sln file. In order to workaround this, I had to patch the workflow file.

@linkdotnet If you've got any insights about the underlying reason behind the initial failure, I'd be a taker :-/

@nulltoken
Copy link
Collaborator Author

nulltoken commented Feb 12, 2025

Weirdo...
image
Looks unrelated to my changes as far as I can tell. Previous builds on this PR pass without any hiccup. I'll blame this on a GitHub transient issue and will give it another try tomorrow....

Ok. For (some) reason, .NET SDK now doesn't detect anymore the .sln file. In order to workaround this, I had to patch the workflow file.

@linkdotnet If you've got any insights about the underlying reason behind the initial failure, I'd be a taker :-/

As far as I can tell this might be related to a new deployed .NET SDK version.

Installed version is 8.0.405 & dotnet-install: Installed version is 9.0.102 => Pass
Installed version is 8.0.406 & Installed version is 9.0.200 => Fail

I've just retriggered a previously passing action. It now fails.
Action 13272577713 => Attempt 1 => Green (https://github.com/NCronJob-Dev/NCronJob/actions/runs/13272577713/attempts/1)
Action 13272577713 => Attempt 2 => Red (https://github.com/NCronJob-Dev/NCronJob/actions/runs/13272577713/attempts/2)

@nulltoken
Copy link
Collaborator Author

Might be the CLI is "starting" to consider .slnx files (cf. dotnet/sdk#40913 (comment))?

@linkdotnet
Copy link
Member

linkdotnet commented Feb 12, 2025

In any case, we could easily just delete the slnx file. Given that it is super trivial to re-create the file, once we are sure that it works.

@@ -33,11 +33,11 @@ jobs:
9.0.x

- name: Restore dependencies
run: dotnet restore
run: dotnet restore ./NCronJob.sln
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's delete the SLNX for now. It is still not stable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


public static class EventsHelper
{
public static IList<ExecutionProgress> WithOrchestrationId(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure if the name sits right with me.
It might imply we Concat the events list with a new orch-Id.
Maybe?

  • FilterByOrchestrationId
  • ForOrchestration

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -158,28 +157,23 @@ public async Task InstantJobCanStartADisabledJob(Func<IInstantJobRegistry, strin

await provider.GetRequiredService<IHostedService>().StartAsync(CancellationToken);

Guid scheduledOrchestrationId = events[0].CorrelationId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Guid scheduledOrchestrationId = events[0].CorrelationId;
var scheduledOrchestrationId = events[0].CorrelationId;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

return events.Where(e => e.CorrelationId == orchestrationId).ToList();
}

public static void AssertScheduledThenCancelled(IList<ExecutionProgress> events)
Copy link
Member

@linkdotnet linkdotnet Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to follow the shouldly style here?
AKA: ShouldBeScheduledThenCancelled(this ILIst<ExectuionProgress>)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@nulltoken nulltoken merged commit a80bc6b into main Feb 12, 2025
5 checks passed
@nulltoken nulltoken deleted the ntk/events_helper branch February 12, 2025 18:38
@nulltoken
Copy link
Collaborator Author

Next up in the queue: rewriting NCronJobIntegrationTests.

This one is going to be tedious. Hopefully, some of the changes introduced in that PR should make it a tad less cumbersome.

@linkdotnet
Copy link
Member

Really appreciate your work @nulltoken

It is a curse and a blessing. As I am a bit full with tasks and can't always find the energy and motivation to work on NCronJob, I know that there is someone doing a fantastic job - leading me more towards being passive. But really - appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants