Name: go-binmock
Owner: Pivotal Cloud Foundry
Description: null
Created: 2017-04-20 14:50:00.0
Updated: 2017-11-08 08:23:35.0
Pushed: 2017-10-27 11:27:08.0
Homepage: null
Size: 49
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.
Creating a mock binary and getting its path:
Monit = binmock.NewBinMock(ginkgo.Fail)
tPath := mockMonit.Path
gToTest := NewThingToTest(monitPath)
Setting up 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)
Asserting 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"))
For a working example you can look at backup-and-restore-sdk