Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple Go mock framework for executables in the command line.
Go
branch: master
Failed to load latest commit information.
.gitignore
.travis.yml
AUTHORS
LICENSE
README.md
example_test.go
mocker.go all: update year in copyright headers
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
}
Something went wrong with that request. Please try again.