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

Ensure parameter handling is coherent #132

Merged
merged 1 commit into from
Nov 4, 2024
Merged

Ensure parameter handling is coherent #132

merged 1 commit into from
Nov 4, 2024

Conversation

nulltoken
Copy link
Collaborator

@nulltoken nulltoken commented Nov 4, 2024

Pull request description

Minor change in parameter handling to ensure that a job parameter value can be overridden through the InstantJobRegistry.

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 Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
src/NCronJob/Registry/JobRun.cs 83.82% <100.00%> (ø)

@linkdotnet
Copy link
Member

Interesting - which case does that cover which wasn't covered before?

@nulltoken
Copy link
Collaborator Author

Interesting - which case does that cover which wasn't covered before?

This one. I stumbled onto this while digging deeper into what were the elements of a JobDefinition uniqueness.

Definition of a job with a standard "configuration" (passed through the parameter).
Temporary overriding of that job "configuration" at runtime through the one-of execution of the job.

    [Fact]
    public async Task InstantJobCanOverrideInitiallyDefinedParameter()
    {
        ServiceCollection.AddNCronJob(
            n => n.AddJob<ParameterJob>(o => o.WithCronExpression("* * 31 2 *").WithParameter("Hello from AddNCronJob")));

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

        provider.GetRequiredService<IInstantJobRegistry>().RunInstantJob<ParameterJob>("Hello from InstantJob");

        var content = await CommunicationChannel.Reader.ReadAsync(CancellationToken);
        content.ShouldBe("Hello from InstantJob");
    }

The other tests were added/modified to have a more comprehensive suite in that context.

@linkdotnet
Copy link
Member

Thanks for the clarification!

@nulltoken
Copy link
Collaborator Author

@linkdotnet Changelog has been updated

@linkdotnet linkdotnet merged commit daa79a9 into main Nov 4, 2024
4 checks passed
@linkdotnet linkdotnet deleted the ntk/parameter branch November 4, 2024 18:21
@nulltoken nulltoken mentioned this pull request Nov 4, 2024
Merged
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