Testing golugin via tyk test utils

Hi!

We want to develop some goplugins. At this point it is a question of how we will test them.

The project is formed as a separate project in golang with its own go.mod

We read the information on this page tyk/TESTING.md at v4.3.0 · TykTechnologies/tyk · GitHub and decided to use this feature, but got an error

Please help us to solve this problem or advise us how to test golugins correctly.

I have asked internally about this. I will revert when I get feedback.

I have got some feedback.

From what I have gathered, I do not think this would work. We don’t have a specific test suite for go plugins. The issue is that they’re strongly dependent of the version of the GW, hence, if you want to test a go plugin you need to compile the plugin with the plugin compiler version that matches with the GW version that you are executing.

You could probably use https://github.com/TykTechnologies/tyk/blob/v4.3.0/TESTING.md#initializing-test-server to write the test but you would most likely need something like:

  • Compile the plugin that is compatible with the tyk version that is being executed. (If done locally then just go build should do the work)
  • Write the test by creating and API that loads the plugin compiled in the previous step
  • Consume the api, and maybe check headers or whatever is being modified.
1 Like