Documentation ¶
Overview ¶
Package matcher provides Gomega TDD matchers for certain whalewatcher elements, such as for matching container names or IDs.
Index ¶
- func BeAContainerEvent(matchers ...types.GomegaMatcher) types.GomegaMatcher
- func HaveEventType(evtype engineclient.ContainerEventType) types.GomegaMatcher
- func HaveID(id interface{}) types.GomegaMatcher
- func HaveName(name interface{}) types.GomegaMatcher
- func HaveOptionalField(field string, expected interface{}) types.GomegaMatcher
- func HaveProject(name string) types.GomegaMatcher
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeAContainerEvent ¶
func BeAContainerEvent(matchers ...types.GomegaMatcher) types.GomegaMatcher
BeAContainerEvent succeeds when the actual value is a ContainerEvent and additionally all passed matchers also succeed.
func HaveEventType ¶
func HaveEventType(evtype engineclient.ContainerEventType) types.GomegaMatcher
HaveEventType succeeds if the actual value has a "Type" field with the specified ContainerEventType value.
func HaveID ¶
func HaveID(id interface{}) types.GomegaMatcher
HaveID succeeds if the actual value has an "ID" field and matches the specified id.
Example ¶
container := whalewatcher.Container{ Name: "foolbar", ID: "12deadbeef89", } Expect(container).To(HaveID("12deadbeef89")) Expect(container).NotTo(HaveID("foobar"))
Output:
func HaveName ¶
func HaveName(name interface{}) types.GomegaMatcher
HaveName succeeds if the actual value has a "Name" field and matches the specified name.
Example ¶
container := whalewatcher.Container{ Name: "foolbar", ID: "12deadbeef89", } Expect(container).To(HaveName("foolbar")) Expect(container).NotTo(HaveName("foobar"))
Output:
Example (NameAndID) ¶
container := whalewatcher.Container{ Name: "12deadbeed89", ID: "12deadbeef89", } Expect(container).To(Or(HaveName("foolbar"), HaveID("12deadbeef89")))
Output:
func HaveOptionalField ¶
func HaveOptionalField(field string, expected interface{}) types.GomegaMatcher
HaveOptionalField succeeds if actual is a struct and the value of the specified field matches the specified matcher; it is no error for the field to be non-existing, this matcher then does not fail, but it also does not succeed either.
Example ¶
project := whalewatcher.ComposerProject{ Name: "myproj", } // Do not pass ComposerProject by value, as it contains a lock. Expect(&project).To(HaveOptionalField("Name", "myproj")) Expect(&project).NotTo(HaveOptionalField("Name", "steven's-proj")) Expect(&project).NotTo(HaveOptionalField("ID", "1234"))
Output:
func HaveProject ¶
func HaveProject(name string) types.GomegaMatcher
HaveProject succeeds if the actual value has a "Project" field and matches the specified project name.
Example ¶
container := whalewatcher.Container{ Name: "foolbar", ID: "12deadbeef89", Project: "myproj", } Expect(container).To(HaveProject("myproj")) Expect(container).NotTo(HaveProject("fred's-project"))
Output:
Types ¶
This section is empty.