Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

vmware-archive/go-binmock

Repository files navigation

go-binmock

Build Status

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.

Usage

Creating a mock binary and getting its path:

mockMonit = binmock.NewBinMock(ginkgo.Fail)
monitPath := mockMonit.Path

thingToTest := NewThingToTest(monitPath)

Setting up expected interactions with the binary:

mockMonit.WhenCalledWith("start", "all").WillExitWith(0)
mockMonit.WhenCalledWith("summary").WillPrintToStdOut(output)
mockMonit.WhenCalledWith("summary").WillPrintToStdOut(output).WillPrintToStdErr("Noooo!").WillExitWith(1)

Asserting on the interactions with the binary, after the fact:

Expect(mockPGDump.Invocations()).To(HaveLen(1))
Expect(mockPGDump.Invocations()[0].Args()).To(Equal([]string{"dbname"}))
Expect(mockPGDump.Invocations()[0].Env()).To(HaveKeyWithValue("PGPASS", "p@ssw0rd"))

For a working example you can look at backup-and-restore-sdk

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages