-
Notifications
You must be signed in to change notification settings - Fork 3
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
QUESTION: dependency injection for unit tests #1
Comments
Ah! I'm Doing It Wrong! What I need to do here is to abstract the function code into its own file and then compose it with So something like this:
And then in my endpoint Lambda:
|
Leaving this open in case @rayepps or anyone else wants to comment further |
Hey @kpeters-cbsi thanks for bringing this up! So the way I do it is I keep it all in one file, I just export the endpoint function. In your first example, I would just add |
So how do you do dependency injection for testing with this framework? Say I have a function,
listThings
, implemented like so:(As I'm sure you can deduce, I lifted a lot of this pattern from your published endpoint code)
So two things to note here:
First, there's no framework code here. While this is intended to run in Lambda / API Gateway, my goal is to be able to compose the framework code from Exobase with my function code so that I can very easily port this to another framework if need be.
Second, I'm loading my
config
in the function definiiton forlistThings
. If I want to use a customconfig
for my tests, how am I supposed to inject that? Or should I just mock the call tomakeStorageService
?The text was updated successfully, but these errors were encountered: