when i access the uri twice in one test, i must gock.New(Uri) twice too
seanjoe opened this issue · comments
my func is
{
defer gock.Off()
gock.New("https//url.com").Get("path").Reply(200)
gock.New("https//url.com").Get("path").Reply(200)
gock.Observe(gock.DumpRequest)
// some test in the func maybe access url twice or more
}
if i use once, other access got Matches: false
why
You could use:
gock.New("https//url.com").Get("path").Reply(200).Times(2)
For more information, see the docs:
https://godoc.org/github.com/h2non/gock#Request.Times
thank you!I think it is a temporary solution, i must estimate the times before use or set a big number in haste.
Alternatively, you can use .Persist()
method, which will guarantee the mock is alive unless you explicitly turn gock
off. See:
https://godoc.org/github.com/h2non/gock#Request.Persist