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

Resolve / #244 #261

Merged
merged 6 commits into from
Oct 22, 2024
Merged

Resolve / #244 #261

merged 6 commits into from
Oct 22, 2024

Conversation

ayaan-qadri
Copy link
Contributor

@ayaan-qadri ayaan-qadri commented Oct 9, 2024

Resolve #244

What Added/Updated

It now supports the --function and -f switches. If either switch is used in the command sls wsgi manage --function <function_name> or -f <function_name>, it will take that function name. If the specified function is not found, it will throw an error, which is handled in invokeHandler. If neither switch is present, it will return the first function with the condition handler: wsgi_handler.handler, as it did before. Let me know if you need any more changes/help!

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.

Project coverage is 97.55%. Comparing base (f6eee36) to head (cf4b544).

Files with missing lines Patch % Lines
index.js 63.63% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #261      +/-   ##
==========================================
- Coverage   98.18%   97.55%   -0.63%     
==========================================
  Files           5        5              
  Lines         605      613       +8     
  Branches       72       75       +3     
==========================================
+ Hits          594      598       +4     
- Misses         11       15       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@logandk
Copy link
Owner

logandk commented Oct 10, 2024

Hi @ayaan-qadri,
Thanks for the PR, great work! Would you be able to add a test case for this feature?

@ayaan-qadri
Copy link
Contributor Author

Hello @logandk, I’d be happy to add a test case for this feature, but I need some guidance on how to do it.

@logandk
Copy link
Owner

logandk commented Oct 10, 2024

You could create a new test case by copying this one:

it("calls handler to execute manage commands remotely from argument", () => {

If you change the plugin configuration to contain multiple functions and add your new argument to the invocation, you can verify that the right function is being called (this line:

expect(plugin.options.function).to.equal("app");
)

@ayaan-qadri
Copy link
Contributor Author

@logandk , I have never written test cases before. If you could tell me more or provide some resources on how to write them, I might be able to do it.

@logandk
Copy link
Owner

logandk commented Oct 11, 2024

@ayaan-qadri Essentially, you'll need to write a piece of code that uses the new feature that you've implemented and assert that it does the right thing. Since we're not testing the Serverless framework or AWS, we simply verify that the right Serverless command is going to be issued.

You can run the existing test suite using npm test. Try starting out with copying the existing test case so you'll be adding another test to the suite. You can then modify the inputs to provide two handler functions and the command to include the -f argument. Finally, assert that the right function is being called. I think if you read through the test case I linked, it will make sense to you what is set up, invoked and asserted at the end.

@ayaan-qadri
Copy link
Contributor Author

Hey @logandk, I have added Test cases for newly feature where it is checking for below conditions:

  1. uses the function specified by --function
  2. uses the function specified by -f
  3. throws an error when specified function is not found
  4. falls back to finding wsgi handler when no function is specified
  5. rejects when no wsgi handler is found and no function is specified

I have added cases for rejection too, Let me know if there are any changes that need to be made.

@logandk
Copy link
Owner

logandk commented Oct 14, 2024

@ayaan-qadri Awesome, thanks for your effort. It looks like something else is messing up the CI pipeline at the moment (probably an update in ESLint that broke the build). I will look into that soon and get your PR merged.

@ayaan-qadri
Copy link
Contributor Author

@logandk Thanks for the update, Let me know if you need anything from my side to get it sorted.

@logandk logandk merged commit ed49693 into logandk:master Oct 22, 2024
0 of 3 checks passed
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.

Provide function to execute when calling sls wsgi command
2 participants