maraino / go-mock

A mocking framework for the Go Programming Language.
MIT License
35 stars 12 forks source link

Mock not working #2

Closed hgfischer closed 10 years ago

hgfischer commented 10 years ago

Hi, I'm trying to use this tool but I got no success. See the following snippets and output I got:

func TestMessageSender(t *testing.T) {
        connMock := new(RedisConnMock)
        connMock.When("Close").Return(nil).Times(1)
        connMock.When("Do", "PSTEX", mock.Any, int64(259200000), mock.Any).Return(nil, nil).Times(1)
        connMock.When("Do", "PUBLISH", "SEND_QUEUE", mock.Any).Return(0, nil).Times(1)
--- FAIL: TestMessageSender (0.00 seconds)
panic: Mock call missing for Do(
    "PSETEX",
    "2f9888cf-ca90-3cf4-b4d0-441b66bc03ba",
    int64(259200000),
    "{\"uuid\":\"2f9888cf-ca90-3cf4-b4d0-441b66bc03ba\",\"envelope\":...}",
) [recovered]
    panic: Mock call missing for Do(
    "PSETEX",
    "2f9888cf-ca90-3cf4-b4d0-441b66bc03ba",
    int64(259200000),
    "{\"uuid\":\"2f9888cf-ca90-3cf4-b4d0-441b66bc03ba\",\"envelope\":...}",
)

Can you help me, please?

maraino commented 10 years ago

It panics because the method Do is not called with the string "PSETEX", as it's defined as "PSTEX", without the E