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

WireMock.Net TestContainer - Docker Logs contain Template references a helper that cannot be resolved. Helper Linq, only on Github Action #1244

Closed
epDugas opened this issue Jan 23, 2025 · 10 comments
Assignees
Labels

Comments

@epDugas
Copy link
Contributor

epDugas commented Jan 23, 2025

Using WireMock TestContainers.
I have an integration test that is only failing when executed during a Github Action. I do not experience this issue locally. The docker log message that is related to the test failure is:

Template references a helper that cannot be resolved. Helper \u0027Linq\u0027

The handlebar template string I am using is:

"{{Linq request.bodyAsJson 'it.requests.Count()'}}"

The github test runner OS is:
Ubuntu
24.04.1

This test was working as of yesterday during the Github Workflow, and seems to have broke suddenly.
Any help/guidance would be greatly appreciated.

@epDugas
Copy link
Contributor Author

epDugas commented Jan 23, 2025

Apologies, I should have reviewed recent releases. I see that dynamic linq was disabled. Request suggestion to achieve the same as the above.

"{{Linq request.bodyAsJson 'it.requests.Count()'}}"

which is to get the count of a json array contained in a property named "requests" in the request.bodyAsJson.

@epDugas
Copy link
Contributor Author

epDugas commented Jan 25, 2025

I submitted a PR at Handlebars.Net.Helpers to add an Enumerable.Count helper.
I looked at adding a custom helper with HandlebarsRegistrationCallback, but did not see a "hook" to add this to the WireMock.Net TestContainer. builder.

@StefH
Copy link
Collaborator

StefH commented Jan 25, 2025

@epDugas
Thank you. I left a review comment at, Handlebars-Net/Handlebars.Net.Helpers#113.
Can you take a look?

@StefH
Copy link
Collaborator

StefH commented Jan 26, 2025

BTW I was thinking, can't you use the length ?

In handlebars.js, this does seem tot work:
https://handlebarsjs.com/playground.html

Image

@StefH
Copy link
Collaborator

StefH commented Jan 26, 2025

@StefH
Copy link
Collaborator

StefH commented Jan 26, 2025

#1245

@epDugas
Copy link
Contributor Author

epDugas commented Jan 26, 2025

Thanks @StefH . I tried various things and didn't have any luck. Just tried the following template string again just to verify, and didn't have any luck (the result was null). Just some additional info, I am using this in a static mapping file:

{{request.bodyAsJson.requests.length}}

Request:

"BodyAsJson": {
  "requests": [
    {
      "code": "3881",
      "value": "updatedValue"
    }
   ]
},

@StefH
Copy link
Collaborator

StefH commented Jan 27, 2025

I've just released NuGet 1.7.1 which includes your handlebars update.

And later today, I'll also release new Docker version.

@StefH
Copy link
Collaborator

StefH commented Jan 27, 2025

Docker images 1.7.1 are available.

@epDugas
Copy link
Contributor Author

epDugas commented Jan 27, 2025

Confirmed, closing.

@epDugas epDugas closed this as completed Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants