Skip to content

🐟🎭 Quick and powerful fish shell mocks

License

Notifications You must be signed in to change notification settings

matchai/fish-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fish Performance arts masks

fish-mock

Quick and powerful fish shell mocks

Build Status Fish Version License


fish-mock provides a quick and easy way to override the behavior of commands for use when testing. Mocking commands causes them to behave predictably, allowing you isolate and focus on the code being tested.

Installation

fisher add matchai/fish-mock

Usage

$ mock

  Usage
    $ mock <command> <argument> [exit code] [executed code]
    $ unmock <command>

  Arguments
    command        The command you would like to have mocked
    argument       The argument the mock should apply to ('*' defines a fallback for all arguments)
    exit code      The exit code returned when the command executes
    executed code  Code to be executed when the command is called with the given argument

  Examples
    $ mock git pull 0 "echo This command successfully echoes"
    $ mock git push 1 "echo This command fails with status 1"
    $ mock git \*   0 "echo This command acts as a fallback to all git commands"
    $ unmock git      # Original git functionality is now restored

  Tips
    To view this manual, use the mock command without providing arguments.
    The array of arguments ($argv) is accessible within mocked functions as $args.
    Many mocks can be applied to the same command at the same time with different arguments.
    Be sure to escape the asterisk symbol when using it as a fallback (\*).

License

ISC Β© Matan Kushner