Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testify template results in wrong assert import depending on module cache #153

Closed
mgabeler-lee-6rs opened this issue Mar 16, 2021 · 1 comment

Comments

@mgabeler-lee-6rs
Copy link

go.mod:

module example

go 1.16

require github.com/stretchr/testify v1.7.0 // indirect

example.go:

package example

func Foo(in string) string {
    return in
}

run: gotests -template testify -only '^Foo$' ./example.go

Output:

package example

import (
	"testing"

	"gotest.tools/assert"
)

func TestFoo(t *testing.T) {
// ...
}

Note the import of assert from the wrong package.

If I run go clean -modcache, and then go mod download and then run gotests again, it generates the proper imports.

The output of this tool should not be broken by the presence of unrelated packages in the module cache.

@butuzov
Copy link
Contributor

butuzov commented Mar 23, 2021

It's because of how the imports process works, and testify clearly not provided. I guess I will fix this as part of #152 as it also affects my tests alongside of #154

@butuzov butuzov mentioned this issue Mar 26, 2021
@cweill cweill closed this as completed in d503102 Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants