Here's an example of a test that is cached but shouldn't be: https://github.com/twpayne/go-geom/blob/master/examples/postgis/main_test.go#L18
This particular test uses github.com/ory/dockertest to run an integration test against a PostgreSQL database. It uses Docker which is an external service, and the result should not be cached. Once the test has run one, running go test again prints: $ go test github.com/twpayne/go-geom/examples/postgis ok github.com/twpayne/go-geom/examples/postgis (cached) which is giving me the idea that the results are cached. go test also terminates very quickly, whereas the test normally takes ~8s to run on my machine. On Fri, 12 Apr 2019 at 03:40, Robert Engels <reng...@ix.netcom.com> wrote: > Where are you getting the idea that results are cached? I can't even > figure out how that would be useful in a testing framework - do you mean it > auto-mocks services based on past requests? I've seen nothing like this - > are you sure you just don't have the wrong HTTP header fields, so the HTTP > request is getting cached by a CDN, etc. > > -----Original Message----- > From: twpa...@gmail.com > Sent: Apr 11, 2019 4:44 PM > To: golang-nuts > Subject: [go-nuts] Re: Disable test result caching from within Go code? > > OK, I guess that Go has no solution for this. > > On Friday, March 29, 2019 at 2:20:53 AM UTC+1, twp...@gmail.com wrote: >> >> I have a bunch of integration tests which depend on external services. >> I've added the build tag "integration" for each source file containing such >> tests so they are only run when I do: >> $ go test -tags=integration ./... >> >> Go 1.12, by default, caches the tests results, which is exactly what I >> don't want because these "external services" are usually different backends >> running on my local machine. When I'm developing code, I want to test my >> code against the current backend running on my local machine, and not have >> "go test" return the result from running the tests against the previous >> backend. >> >> I can disable caching by passing the "-count=1" argument to "go test" but >> this is a pretty blunt instrument: I need to remember when I'm running an >> integration test and when I'm not, and it applies to the whole set of tests >> that I'm running. >> >> Ideally I'd like to specify within each test whether the result can be >> cached or not. I looked at the documentation for testing >> <https://godoc.org/testing>, but the word "cache" is not present, >> >> Is there any way for Go test code to control whether its results should >> be cached? >> >> Cheers, >> Tom >> > -- > 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 golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > > > > > -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.