Package suggestion for _test.go#1220
Package suggestion for _test.go#1220ramya-rao-a merged 13 commits intomicrosoft:masterfrom uudashr:package-suggestion
Conversation
|
@ramya-rao-a please check |
src/goSuggest.ts
Outdated
| } | ||
|
|
||
| if (goFilename.endsWith('internal_test.go')) { | ||
| return resolve(basename(dirname(filename))); |
There was a problem hiding this comment.
Can you point me to any docs that talk about this as a standard?
There was a problem hiding this comment.
There are practice to make a test package to test un-exported method when necessary.
No official docs but here:
- https://medium.com/@matryer/5-simple-tips-and-tricks-for-writing-unit-tests-in-golang-619653f90742
- https://blog.alexellis.io/golang-writing-unit-tests/
Hmm.. I found not too much:
$ find /usr/local/Cellar/go/1.9/libexec/src | grep internal_test.go
/usr/local/Cellar/go/1.9/libexec/src/net/http/transport_internal_test.go
/usr/local/Cellar/go/1.9/libexec/src/os/exec/internal_test.go
/usr/local/Cellar/go/1.9/libexec/src/strconv/internal_test.go
/usr/local/Cellar/go/1.9/libexec/src/time/internal_test.go
| - Quick Info (using `gogetdoc` or `godef`+`godoc`) | ||
| - Goto Definition (using `gogetdoc` or `godef`+`godoc`) | ||
| - Find References (using `guru`) | ||
| - Find implementations (using `guru`) |
There was a problem hiding this comment.
Merge from master, there are a lot of changes there
There was a problem hiding this comment.
I'm rebase from the master, seems not good rebase to an existing PR
There was a problem hiding this comment.
@ramya-rao-a Do you want me to re-create clean PR?
There was a problem hiding this comment.
Yes please, let's just do that. There is too much noise this PR.
|
Also add package suggestion when the directory name formed by multiple words, ex:
|
|
@uudashr I have rebased from master. Can you check if everything is as you expected? |
src/util.ts
Outdated
|
|
||
| export function readDir(path): Promise<string[]> { | ||
| return new Promise<string[]>((resolve, reject) => { | ||
| fs.readdir(path, (err, files) => { |
There was a problem hiding this comment.
instead of getting all files under the path and then checking for main.go, isn't it simpler to directly check for path + 'main.go' using fs.statSync(filePath).isFile() ?
|
@uudashr Also updated to use |
|
@ramya-rao-a fs.stat() such a great idea |
|
@uudashr I also moved the whole pkg guessing logic to the utils file to make it re-usable as well as unit testable. When you have some time, can you add unit tests for that function? For all the cases that you have in the comments? |
Assume the directory name is
messagingpackage main*_test.go=> suggestionpackage messaging_test*internal_test.goand rest of*.go=> suggestionpackage messaging