repositorypackage
1.2.1
Repository: https://github.com/jaredallard/cmdexec.git
Documentation: pkg.go.dev
# README
cmdexec
Go library for mocking exec.Command
and exec.CommandContext
calls.
Aims to provide an as close as possible [exec.Cmd]-like interface for
drop-in support.
Differences
- Instead of setting
cmd.Stdin
(orin/err
), useSetStdin()
functions instead. This is due to those being fields on a struct, which cannot be on an interface.
Usage
See our Go docs.
Asserting Output
Normally, you shouldn't need to assert anything as your function that executes a command should give you testing signal (is it working or not :wink:). However, you can assert certain fields with this library. Currently, this is limited to Stdin checking.
If you set [MockCommand.Stdin] and call SetStdin
in the function
executing a command, Stdin
will be checked to ensure it is equal. This
is to allow greater testing if required.
License
LGPL-3.0