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

Reuse path variable for bodyfile #176

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

eloo-abi
Copy link

Hi,
this PR enables the usage of the variables defined in the imposters to be reused in the bodyFile path.
So we can use "dynamic" responses for different paths easily.
Fixes: #175

@joanlopez
Copy link
Member

Hey @eloo-abi! Thanks for your contribution 💟 However, before moving forward, I'd like to see some tests that show the expected behavior in different scenarios (e.g. no variables at all, a variable with a single value, a variable with multiple values, multiple variables, when a non-defined variable is used, etc).

@joanlopez joanlopez requested review from joanlopez and aperezg and removed request for joanlopez August 21, 2024 07:59
@eloo-abi
Copy link
Author

eloo-abi commented Aug 21, 2024

Hi,

no variables at all

this is covered by the existing tests already as the implementation is not going to change anything here

a variable with a single value

will be added

a variable with multiple values

not sure what this is, can you give an example of a variable with multiple values?

multiple variables

will be added

when a non-defined variable is used

it behaves like a wrong manually entered path as the implementation is not doing anything special, just adjust the path to search for a file

@joanlopez
Copy link
Member

joanlopez commented Aug 21, 2024

Hi,

no variables at all

this is covered by the existing tests already as the implementation is not going to change anything here

a variable with a single value

will be added

a variable with multiple values

not sure what this is, can you give an example of a variable with multiple values?

multiple variables

will be added

when a non-defined variable is used

it behaves like a wrong manually entered path as the implementation is not doing anything special, just adjust the path to search for a file

Yes, please, ignore the case of multiple values for a single variable (I left a comment in the issue).
Cover the rest, and we can go! 🚀

Merge in OSSC/killgrave from feature/friendsofgoGH-175-reuse-path-variable-for-bodyfile to feat/friendsofgoGH-175-reuse-path-variable-for-bodyfile

* commit '18e28e7f7c16c2a4fc670f2aae6b744a82c1be51':
  remove unused line
  test: add tests for variables in body file
@eloo-abi
Copy link
Author

tests added

i was not sure where or how to add to i have added it similar to other handler_tests
i hope this makes sense

@eloo-abi
Copy link
Author

@joanlopez
hi, any news near?
if everything fits your needs maybe we can merge this?

thanks

expectedBodyPath string
statusCode int
}{
{"valid imposter with id 1 in path", imposters[0], "/gophers/1", responseId1, http.StatusOK},
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test case where there's a value defined in the bodyFile path but not in the endpoint, please? Just to reflect what's the expectation in such case.

Copy link
Author

Choose a reason for hiding this comment

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

for sure..
but this is the same behaviour as right now if the file could not be found

"200" with empty body

@joanlopez
Copy link
Member

@joanlopez hi, any news near? if everything fits your needs maybe we can merge this?

thanks

Hey @eloo-abi! Sorry for the delay, I've been quite busy during recent weeks.
I left some comments and suggestions, I think that, once fixed, it will be good enough to be merged, for me.

Thanks! 🙇🏻

Merge in OSSC/killgrave from feature/friendsofgoGH-175-reuse-path-variable-for-bodyfile to feat/friendsofgoGH-175-reuse-path-variable-for-bodyfile

* commit 'c9dbb4b7afa8c138d678ba338d7f4be397297034':
  fix: adjust test data and handle errors
@eloo-abi
Copy link
Author

@joanlopez everything should be addressed :)

@eloo-abi
Copy link
Author

@joanlopez did you have already time to have a look?

@joanlopez
Copy link
Member

@joanlopez did you have already time to have a look?

Been AFK for some time during September, but planning to review it during October for sure! 🙇🏻

responseId2 := "test/testdata/imposters_variables/responses/gopher_2_response.json"
responseId1Variable1 := "test/testdata/imposters_variables/responses/gopher_1_1_response.json"
responseId1Variable2 := "test/testdata/imposters_variables/responses/gopher_1_2_response.json"
responseId1WithoutVariable := "test/testdata/imposters_variables/responses/gopher_1_without_variable_response.json"
Copy link
Member

Choose a reason for hiding this comment

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

Nit; I think this could be refactored in a way so we use the file contents in the test (instead of the file path), so we don't need an empty file for the case where there's no data, but it's not critical/blocking for merging this PR.

Copy link
Member

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

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

Hey! I left a minor comment, in case you want to address it, but overall looks good! 👍🏻
Thanks 🙇🏻

@eloo-abi
Copy link
Author

@joanlopez if its not a blocker please merge this PR as it takes already a very long time for such a small change

@joanlopez
Copy link
Member

@joanlopez if its not a blocker please merge this PR as it takes already a very long time for such a small change

Yeah, sure! I'm waiting for @aperezg to give his 👍🏻, which I hope we get in the next few days, it's alright from my side! 🙇🏻

@eloo-abi
Copy link
Author

@joanlopez @aperezg any updates here?

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.

Allow variables in bodyFile path
2 participants