How to "import" in go files(test data) of go plugin unit test?

Answered

I want to write tests for an intention action of my go plugin.
The action will first check the expression of a call whether `pkg/errors.Wrapf`, but in my unit test, the `errors.Wrapf` never resolve to `pkg/errors.Wrapf`.
I don't known how to make the resolution a success, the intellij sdk docs do not mention how to test go plugin, should I just use `ApplicationManager.getApplication().isUnitTestMode()` to bypass the signature check?

5 comments
Comment actions Permalink

Do you target GoLand IDE? For more details regarding GoLand plugin development check our docs: https://plugins.jetbrains.com/docs/intellij/goland.html

0
Comment actions Permalink

Yes, I do target GoLand IDE. I already read the doc https://plugins.jetbrains.com/docs/intellij/goland.html and can't find anything about plugin testing.
After skimming the intellij go plugin source code, I guess I need to setup `GoSdkService` correctly, but I don't known how to do it.

0
Comment actions Permalink

Sorry for the delay! Can you please provide your Gradle/plugin.xml configurations?

0
Comment actions Permalink

Thanks for your reply! I already found the solution after reading the source code in go.zip and the test code in https://github.com/go-lang-plugin-org/go-lang-idea-plugin. It's not about build configuration, I need to setup some paths which point to sdk (mock) file and library file via `GoApplicationLibrariesService.getInstance().setLibraryRootUrls` and `GoSdkService.getInstance(project).setSdk`.

0
Comment actions Permalink

I'm glad you've managed it. Thanks for the update!

0

Please sign in to leave a comment.