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

Feature/sc 124023/execute refactor #707

Merged

Conversation

hugomontero
Copy link
Contributor

@hugomontero hugomontero commented Jan 3, 2024

Description

This PR will re-define the accepted params for execute and deploy and also use class pattern for logic function deploy and execute commands

How to Test

  • Pull down the branch: git pull && git checkout feature/sc-124023/execute-refactor
  • Install dependencies: npm i
  • Run tests: npm run test:ci & npm run test:e2e -- --grep "Logic Function Commands"
  • Run over the follow suggested tests:

Suggested tests:

Execute LF without params:

Having a current Logic function (you can use npm start -- lf create to create a fresh one) run:

  • npm start -- lf execute /my/logic/function/path
  • npm start -- lf execute /my/logic/function/path/file.js
  • npm start -- lf execute /my/logic/function/path/file.logic.js

outcome

  • In every case you will be able to execute your logic function succesfully.

Execute LF using --name --id

Having a current Logic function (you can use npm start -- lf create to create a fresh one) run:
In case of the --id use the command npm start -- lf get --name <logic-function-name> in order to download an existent LF

  • npm start -- lf execute /my/logic/function/path --name <logic-function-name>
  • npm start -- lf execute /my/logic/function/path --name "wrong name"
  • npm start -- lf execute /my/logic/function/path --id <logic-function-id>

outcome

  • With the right name the logic function will be executed
  • With the wrong name it will show a message indicating that the logic function was not found
  • With the id, in case the logic.json file contains id then it will be executed successfully

Execute LF using a path with several LF inside

Having a several Logic functions (you can use npm start -- lf create to create fresh ones) run:

  • npm start -- lf execute /my/logic/function/path

outcome

  • You will be prompted to pick one logic function from the list

Execute LF using a path with several LF inside with malformed ones

Having a several Logic functions (you can use npm start -- lf create to create fresh ones) run:

  • Pick one logic function file pack and delete the .js
  • npm start -- lf execute /my/logic/function/path

outcome
You will see a message indicating that there is a malformed logic function and the related error (in this case: .js doesn't exist)

Common cases

  • Attempt to use the follow params:
    • device_id
    • product_id
    • data
    • payload

Deploy logic functions

Suggest to use the same tests than before just with deploy command instead

Related Issues / Discussions

Story details: https://app.shortcut.com/particle/story/124023

Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA
  • Problem and solution clearly stated
  • Tests have been provided
  • Docs have been updated
  • CI is passing

@hugomontero hugomontero marked this pull request as ready for review January 3, 2024 18:24
@hugomontero hugomontero force-pushed the feature/sc-124023/execute-refactor branch from 7f8c87a to bfda1bb Compare January 3, 2024 19:36
Copy link
Contributor

@keeramis keeramis left a comment

Choose a reason for hiding this comment

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

👍

@hugomontero hugomontero merged commit ccffed4 into feature/logic-function Jan 4, 2024
6 checks passed
@monkbroc monkbroc deleted the feature/sc-124023/execute-refactor branch January 19, 2024 19:41
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