Name: go-binmock
Owner: Buildkite
Description: null
Forked from: pivotal-cf/go-binmock
Created: 2017-09-07 01:27:23.0
Updated: 2017-09-07 01:27:25.0
Pushed: 2017-08-07 17:28:13.0
Homepage: null
Size: 44
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A library to mock interactions with collaborating executables. It works by creating a fake executable that can be orchestrated by the test. The path of the test executable can be injected into the system under test.
Create a mock binary and getting its path.
Monit = binmock.NewBinMock(ginkgo.Fail)
tPath := mockMonit.Path
gToTest := NewThingToTest(monitPath)
Setup expected interactions with the binary
Monit.WhenCalledWith("start", "all").WillExitWith(0)
Monit.WhenCalledWith("summary").WillPrintToStdOut(output)
Monit.WhenCalledWith("summary").WillPrintToStdOut(output).WillPrintToStdErr("Noooo!").WillExitWith(1)
Assert on the interactions with the binary, after the fact
ct(mockPGDump.Invocations()).To(HaveLen(1))
ct(mockPGDump.Invocations()[0].Args()).To(Equal([]string{"dbname"}))
ct(mockPGDump.Invocations()[0].Env()).To(HaveKeyWithValue("PGPASS", "p@ssw0rd"))