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

Add Marten end-to-end test using MartenOps #427

Merged

Conversation

schnerring
Copy link
Contributor

Add orders/create handler demonstrating MartenOps issue: #426

@schnerring schnerring force-pushed the add-marten-e2e-sideeffect-tests branch from b12c600 to 0ea4a4b Compare June 23, 2023 03:37
@schnerring schnerring changed the title Add failing Marten end-to-end test using MartenOps Add Marten end-to-end test using MartenOps Jun 23, 2023
@jeremydmiller jeremydmiller merged commit 81ab861 into JasperFx:main Jun 27, 2023
1 check passed
@jeremydmiller
Copy link
Member

jeremydmiller commented Jun 27, 2023

@schnerring And this "works on my box". Was this change to the test supposed to fail? If you look at the code generated, it's exactly what it should be doing:

    public class POST_orders_create2 : Wolverine.Http.HttpHandler
    {
        private readonly Wolverine.Http.WolverineHttpOptions _options;
        private readonly Marten.ISessionFactory _sessionFactory;

        public POST_orders_create2(Wolverine.Http.WolverineHttpOptions options, Marten.ISessionFactory sessionFactory) : base(options)
        {
            _options = options;
            _sessionFactory = sessionFactory;
        }



        public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext)
        {
            await using var documentSession = _sessionFactory.OpenSession();
            var (command, jsonContinue) = await ReadJsonAsync<WolverineWebApi.Marten.StartOrder>(httpContext);
            if (jsonContinue == Wolverine.HandlerContinuation.Stop) return;
            (var orderStatus, var startStream) = WolverineWebApi.Marten.MarkItemEndpoint.StartOrder2(command, documentSession);
            
            // Placed by Wolverine's ISideEffect policy
            startStream.Execute(documentSession);

            await WriteJsonAsync(httpContext, orderStatus);

            // Commit the unit of work
            await documentSession.SaveChangesAsync(httpContext.RequestAborted).ConfigureAwait(false);
        }

    }

@jeremydmiller jeremydmiller added this to the 1.1.0 milestone Jun 27, 2023
@schnerring
Copy link
Contributor Author

When I openend the PR they were failing. I fixed the tests in 0ea4a4b, which with v1.0.1 could probably be reverted.

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.

None yet

2 participants