Skip to content

troykinsella/mockleton

Repository files navigation

mockleton

Version License Build Status

An executable program mocking tool

Installation

Checkout releases and download the appropriate binary for your system. Put the binary in a convenient place, such as /usr/local/bin/mockleton.

Or, run the handy dandy install script: (Note: go read the script and understand what you're running before trusting it)

export PREFIX=~ # install into ~/bin
wget -q -O - https://raw.githubusercontent.com/troykinsella/mockleton/master/install.sh | bash

Usage

Mocking an Executable

Firstly, you have to make mockleton look like the executable you wish to mock:

$ cd my-project
$ mkdir -p mocks
$ export PATH=$PWD/mocks:$PATH
$ ln -s /usr/local/bin/mockleton $PWD/mocks/program

Now, when you run program (which points to mockleton), it will capture the execution details and produce a report file:

$ echo foo | program bar
$ cat mockleton.out
{
  "mockleton-version": "...",
  "sequence": [
    {
      "exec-spec": {
        "timestamp": "2018-10-10T14:09:31.477900029-07:00",
        "stdin": {
          "content": "foo\n",
          "encoding": "utf-8"
        },
        "args": [
          "program",
          "bar"
        ],
        "env": {
          "EDITOR": "emacs",
          ...
        }
      }
    }
  ]
}

If you run program again, it will append the new execution details to the sequence list in the existing mockleton.out file.

Road Map

  • stubbed outputs
  • basic assertions using gomega

License

MIT © Troy Kinsella