Go mock framework for executables in the command line.
Go
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
AUTHORS
LICENSE
README.md
example_test.go
mocker.go
mocker_test.go

README.md

#commandmocker

Build Status

commandmocker is a simple utility for tests in Go. It adds command with expected output to the path.

For example, if you want to mock the command "ssh", you can write a test that looks like this:

import (
    "github.com/tsuru/commandmocker"
    "testing"
)

func TestScreamsIfSSHFail(t *testing.T) {
    message := "ssh: Could not resolve hostname myhost: nodename nor servname provided, or not known"
    path, err := commandmocker.Error("ssh", message, 65)
    if err != nil {
        t.Fatal(err)
    }
    defer commandmocker.Remove(path)

    // write your test and expectations
}