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

Enable unit testing of the DF API #262

Merged
merged 6 commits into from
Jun 23, 2021
Merged

Conversation

davidmrdavid
Copy link
Collaborator

@davidmrdavid davidmrdavid commented May 11, 2021

Related to: #257

This PR is a first step to facilitating and encouraging unit testing of DF orchestration functions by end-users.

To achieve this, this PR does 2 things:
(1) It removes a layer of indirection in the DF API. Previously, the DF APIs were all defined in the Orchestrator class and dynamically assigned to the OrchestratorContext object at runtime. This made it confusing to mock DF APIs because, while user-code calls APIs on the context object, the user would have to mock the methods defined in the orchestrator class instead.

Now all DF APIs are inlined in the context object itself.

(2) Export a "dummy" orchestrator objects for users to use as a mock/stubbing target. In order to test an orchestrator function, users have to provide it with a context argument, which isn't easy to construct due to framework-internal idiosyncrasies. Now we export an implementation of the context interface that's been prepopulated with dummy values and that can flow through the orchestrator's handle method without exceptions. End users are expected to then mock this object's API endpoints and test their orchestrators through it.

As an aside, this API also happens to update our reference to @azure/functions type declarations, which required a tweak in some of our internal tests. Our .vscode files have also been pretty-fied and slightly updated.

@davidmrdavid davidmrdavid marked this pull request as ready for review May 11, 2021 22:34
@davidmrdavid
Copy link
Collaborator Author

After this PR is merged, remaining action items include:
(1) providing more comprehensive testing samples
(2) adding a reference to this to the official durable docs

Copy link

@ConnorMcMahon ConnorMcMahon left a comment

Choose a reason for hiding this comment

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

Looks good, but a few logistics questions.

"name": "Attach to Node Functions",
"type": "node",
"request": "attach",
"port": 9229,

Choose a reason for hiding this comment

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

Is this port specific to your own local configuration for functions CLI, or can it be any open port?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this can be any open port. However, I didn't manually specify this file so I can't say with certainty, it was autogenerated when setting up my debugging experience, so I suspect the chosen port is the default for these kinds of operations :)

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