STDLIB Testing Mock Function Reference
Index
_mock.arg_string.make.from_array
Generates a mock argument string from an array.
Arguments
$1 (string): The name of the array containing positional arguments.
$2 (string): (optional) The name of the array containing keyword arguments.
Exit codes
0: If the mock argument string was generated.
126: If an invalid argument has been provided.
127: If the wrong number of arguments were provided.
Output on stdout
The generated mock argument string.
_mock.arg_string.make.from_string
Generates a mock argument string from a delimited string.
STDLIB_LINE_BREAK_DELIMITER string keyword: The delimiter used to split the string (default=” “).
Arguments
$1 (string): The delimited string of positional arguments.
$2 (string): (optional) The name of the array containing keyword arguments.
Exit codes
0: If the mock argument string was generated.
125: If an invalid keyword has been provided.
126: If an invalid argument has been provided.
127: If the wrong number of arguments were provided.
Output on stdout
The generated mock argument string.
_mock.clear_all
Clears all calls from all registered mocks.
Function has no arguments.
Exit codes
0: If all registered mocks were cleared.
_mock.create
Creates a new mock object.
Arguments
$1 (string): The name of the function or binary to mock.
Exit codes
0: If the mock object was created successfully.
123: If a variable reserved for use by the BASH stdlib has been assigned an invalid value.
126: If an invalid argument has been provided.
127: If the wrong number of arguments were provided.
Output on stderr
The error message if the operation fails.
_mock.delete
Deletes a mock object and restores its original implementation.
Arguments
$1 (string): The name of the mock to delete.
Exit codes
0: If the mock object was deleted.
127: If the wrong number of arguments were provided.
_mock.register_cleanup
Registers the mock cleanup function with the exit trap.
Function has no arguments.
Exit codes
0: If the cleanup function was registered successfully.
_mock.reset_all
Resets all registered mocks to their default state.
Function has no arguments.
Exit codes
0: If all registered mocks were reset.
_mock.sequence.assert_is
Asserts that the sequence of mock calls matches the expected values.
Arguments
… (array): The expected sequence of mock calls.
Exit codes
0: If the sequence matches.
1: If the sequence does not match.
Output on stderr
The error message if the assertion fails.
_mock.sequence.assert_is_empty
Asserts that no mock calls have been recorded.
Function has no arguments.
Exit codes
0: If the sequence is empty.
1: If the sequence is not empty.
Output on stderr
The error message if the assertion fails.
_mock.sequence.clear
Clears the recorded sequence of mock calls.
Function has no arguments.
Exit codes
0: If the sequence was cleared.
_mock.sequence.record.resume
Resumes recording of mock calls in the sequence.
Function has no arguments.
Exit codes
0: If the recording was resumed.
_mock.sequence.record.start
Starts recording a new sequence of mock calls.
Function has no arguments.
Exit codes
0: If the recording was started.
_mock.sequence.record.stop
Stops recording of mock calls in the sequence.
Function has no arguments.
Exit codes
0: If the recording was stopped.