Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Generate test function from a test file results in error opening file #2822

Closed
pot-code opened this issue Oct 9, 2019 · 8 comments
Closed

Comments

@pot-code
Copy link

pot-code commented Oct 9, 2019

Steps to Reproduce:

  1. create a test file like xxx_test.go
  2. move cursor to a function name(not a function prefixed with Test) and generate a test function, a error message then appears in the corner

What impressed me is that the desired test function is appended to file, without overwriting the current content.

Is there any way to remove the error message? Every time I generate a test function, it will appear.

Though it may be uncommon to do it, but it's useful sometimes, would you mind supporting it?

@ramya-rao-a
Copy link
Contributor

Thanks for reporting @pot-code, can you share the error message you are seeing?

@pot-code
Copy link
Author

Created a file named demo_test.go without the associated demo.go file

Unable to open 'demo.go': Unable to read file (Error: File not found (/Users/xxx/Documents/sandbox/playground/go/src/xxx.lang/spec/demo.go)).

It seems that it tries to open the demo.go file after creating the test function

@ramya-rao-a
Copy link
Contributor

Ah! understood.

The assumption always was that the "generate unit tests" command would be run on a non test file.
So, when the corresponding test file was updated, there was a need to open it.
For this, I re-used the Toggle Test File command.

In your case, the Toggle Test File command fails because the non test file doesnt exist :)

PRs are welcome to fix this bug

@ramya-rao-a ramya-rao-a changed the title Generate test function in a test file Generate test function from a test file results in error opening file Oct 17, 2019
@drakegens
Copy link
Contributor

I will try to take this one on!

@aykejriw
Copy link

@ramya-rao-a If no one is working here, I can do that.

@ramya-rao-a
Copy link
Contributor

I believe @drakegens has a PR out for this that had some feedback they had to react to.
@drakegens Are you planning on continuing your work in #2883?

@drakegens
Copy link
Contributor

drakegens commented Nov 19, 2019 via email

@ramya-rao-a
Copy link
Contributor

This issue is fixed in the latest version (0.13.0) of this extension

Thanks for the PR @drakegens and Thanks for reporting @pot-code !

Happy Coding!

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants