Update pegomock

This commit is contained in:
Luke Kysow
2017-10-29 00:46:39 -07:00
parent eeb39c5e7f
commit 30a37aecfe
3 changed files with 19 additions and 6 deletions

2
Gopkg.lock generated
View File

@@ -149,7 +149,7 @@
branch = "master"
name = "github.com/petergtz/pegomock"
packages = [".","internal/verify"]
revision = "53d177bf13d74db3a7120c60f03d4f42bea4b608"
revision = "b99e34d8f73c46cb5e7fef35963a0b0bb89887eb"
[[projects]]
name = "github.com/pkg/errors"

View File

@@ -173,7 +173,7 @@ func formatParams(params []Param) (result string) {
if i > 0 {
result += ", "
}
result += fmt.Sprint(param)
result += fmt.Sprintf("%#v", param)
}
return
}

View File

@@ -556,8 +556,8 @@ var _ = Describe("MockDisplay", func() {
"Mock invocation count for method \"Flash\" with params [wrong string -987] " +
"does not match expectation.\n\n\tExpected: 1; but got: 0\n\n" +
"\tBut other interactions with this mock were:\n" +
"\tFlash(Hello, 123)\n" +
"\tFlash(Again, 456)\n",
"\tFlash(\"Hello\", 123)\n" +
"\tFlash(\"Again\", 456)\n",
))
})
@@ -569,11 +569,24 @@ var _ = Describe("MockDisplay", func() {
"Mock invocation count for method \"Flash\" with params [wrong string -987] " +
"does not match expectation.\n\n\tExpected: 1; but got: 0\n\n" +
"\tBut other interactions with this mock were:\n" +
"\tFlash(Hello, 123)\n" +
"\tShow(Again)\n"),
"\tFlash(\"Hello\", 123)\n" +
"\tShow(\"Again\")\n"),
)
})
It("formats params in interactions with Go syntax for better readability", func() {
display.NetHttpRequestParam(http.Request{Host: "x.com"})
Expect(func() { display.VerifyWasCalledOnce().NetHttpRequestParam(http.Request{Host: "y.com"}) }).To(PanicWith(
`Mock invocation count for method "NetHttpRequestParam" with params [{ <nil> 0 0 map[] <nil> <nil> 0 [] false y.com map[] map[] <nil> map[] <nil> <nil> <nil> <nil>}] does not match expectation.
Expected: 1; but got: 0
But other interactions with this mock were:
NetHttpRequestParam(http.Request{Method:"", URL:(*url.URL)(nil), Proto:"", ProtoMajor:0, ProtoMinor:0, Header:http.Header(nil), Body:io.ReadCloser(nil), GetBody:(func() (io.ReadCloser, error))(nil), ContentLength:0, TransferEncoding:[]string(nil), Close:false, Host:"x.com", Form:url.Values(nil), PostForm:url.Values(nil), MultipartForm:(*multipart.Form)(nil), Trailer:http.Header(nil), RemoteAddr:"", RequestURI:"", TLS:(*tls.ConnectionState)(nil), Cancel:(<-chan struct {})(nil), Response:(*http.Response)(nil), ctx:context.Context(nil)})
`,
))
})
It("shows no interactions if there were none", func() {
Expect(func() { display.VerifyWasCalledOnce().Flash("wrong string", -987) }).To(PanicWith(
"Mock invocation count for method \"Flash\" with params [wrong string -987] " +