I followed below steps to run tests in go mod. In this process I had few
questions that needs clarification.
1. cd /tmp/gomodtry/tests/src/hello/hello_test.go
package tests
import (
“github.com/stretchr/testify/assert”
“os”
“testing”
)
func GetEnv(key string, fallback string) string {
envVariable := os.Getenv(key)
if envVariable == “” {
return fallback
}
return envVariable
}
func TestHello(t *testing.T) {
val := GetEnv(“check”, “ok”)
assert.Equal(t, “ok”, val, “val is not equal to ok”)
}
func TestHello1(t *testing.T) {
val := GetEnv(“check”, “ok”)
assert.Equal(t, “ok”, val, “val is not equal to ok”)
}
1.
export GO111MODULE=on
2.
go test ./…
This created go.mod and go.sum files in cd /tmp/gomodtry/ location
When I executed go test ./… -v again , it executed the tests
successfully.
QUESTION:
Where is the dependent github.com/stretchr/testify/assert downloaded - I dont
see it downloaded any where.
Before go mod concept when we set GOPATH and then go get dependency, it used to
download physically.
Can you please explain how the test is resolving dependency without the
physical presence of dependent library.
In previous version, when we go get dependencies, some times we used to get 500
error because the host where dependency exists will be down temporarily.
Do we still face this kind of issues with go mod concepts? How is it handled?
[we did not like vendoring of dependencies, so we end up doing go get for every
test run, which made of tests runs unstable when the host went down]
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.