Skip to content

tsuru/commandmocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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
}

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages