Skip to content

[doc] Document that func (*Call) Return can accept functions #818

@KrzysztofMadejski

Description

@KrzysztofMadejski

Functions that computes mock return arguments based on input arguments.

Example: mocking a io.Write function:

mf := mocks.RemoteFile{}
mf.On("Close").Return(tt.sftpErrorFileClose)
mf.On("Write", mock.AnythingOfType("[]uint8")).Return(
	func(input []byte) int { return len(input)}, 
	tt.sftpErrorFileWrite)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions