Closed lays147 closed 4 months ago
Hey! @lays147
Thank you for sending your question! Does the link that @Water-Melon sent above help (☝️)? There's some documentation that should explain how to use kong.ctx (context). Would that work for your use case?
Hi @nowNick no. As I said, the context var on the test pdk is not available. I can use it on writing a plugin, but I can't manage the context on the text setup. Because in this case, I'm retrieving a var from the context, not setting it.
Also, the docs are wrong because to use SetShared
requires a key and value, and the pdk docs shows otherwise. Moreover, it does not make sense to save something in context without a value, only with a key.
Oh! Ok I see. Apologies for the confusion then!
I'll take a deeper look at this and I'll try to offer better guidance / report bugs.
@nowNick I was running into the same issue and created PR #174 which would allow the usage of the shared context during testing.
That's awesome @winslowdibona! Thank you for your contribution!
@nowNick Is there someone specific I should reach out to about reviewing PR #174 ? I've mentioned a few others on there but I haven't gotten any reviews/comments on it in about a week.
Hey @winslowdibona If possible I'd like to merge this one first: https://github.com/Kong/go-pdk/pull/170 and then rebase your PR on top of it. I'll keep track of both of these PRs to make sure they're merged swiftly.
Solved by #174
Hi, I'm trying to write a couple of unit tests for a plugin that I'm doing, and based on the docs, I can't see where I could add a variable to the
kong.context
for the purpose of the unit test.Checking the source code, the Ctx is available at
env.pdk
, but this variable is not available for external access.