golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.3k stars 610 forks source link

Unable to SetArg with chan #509

Open ahl5esoft opened 3 years ago

ahl5esoft commented 3 years ago
type IMQ interface {
    Publish(channel string, message interface{}) error
    Subscribe(channel string, message chan<- string)
}

// Test
mockMQ := mq.NewMockIMQ(ctrl)
message := make(chan string)
mockMQ.EXPECT().Subscribe(
    gomock.Eq("channel"),
    gomock.Any(),
).SetArg(1, message)

// error -> SetArg(1, ...) referring to argument of non-pointer non-interface non-slice type chan<- string