matcher

package
v0.21.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package matcher implements Gomega matchers for lxkns information model artifacts, such as containers and container groups (pods in particular). These matchers can be used in unit tests of applications using the lxkns API and information model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeAContainer

func BeAContainer(opts ...types.GomegaMatcher) types.GomegaMatcher

BeAContainer succeeds if actual is a model.Container or *model.Container and also satisfies all specified option matchers. A typical use is to use BeAContainer in combination with the "WithX" matchers, such as WithName and WithType. Of course, any other matcher can be specified as an option matcher to BeAContainer as needed.

Expect(c).To(BeAContainer(WithName("foobar"), WithType(moby.Type),
    BePaused()))

Checking for the presence of certain containers in slices, arrays and maps is straightforward: simply list the expected combination of container properties, such as not only a specific name, but also being part of a particular Kubernetes pod or Composer project.

Expect(containers).To(ContainElement(BeAContainer(
    WithName("foobar"), BeInAPod(WithName("default/pod")))))

func BeADockerContainer

func BeADockerContainer(opts ...types.GomegaMatcher) types.GomegaMatcher

BeADockerContainer succeeds if actual is a Docker container and also satisfy all option matchers. For instance:

Expect(c).To(BeADockerContainer(WithName("foobar"), BePaused()))

func BeAPod

func BeAPod(opts ...types.GomegaMatcher) types.GomegaMatcher

BeAPod succeeds if actual is a model.Group or a *model.Group and also satisfies all specified option matchers.

Expect(g).To(BeAPod(WithName("default/pod")))

Related: the BeInAPod matchers checks a container to be part of a pod with specific properties.

func BeInAGroup

func BeInAGroup(opts ...types.GomegaMatcher) types.GomegaMatcher

BeInAGroup succeeds if actual is a model.Container or *model.Container and the specified option matchers all succeed on a group the actual container belongs to.

Expect(c).To(BeInAGroup(WithName("my_project")))

func BeInAPod

func BeInAPod(opts ...types.GomegaMatcher) types.GomegaMatcher

BeInAPod succeeds if actual is a model.Container or *model.Container and the container is grouped by a Kubernetes/k8s pod for which all the option matchers also succeed.

Expect(c).To(BeInAPod(WithName("default/mypod")))

func BePaused

func BePaused() types.GomegaMatcher

BePaused succeeds if actual is a model.Container or *model.Container and the container is paused.

Expect(c).To(BePaused())

func HaveLabel

func HaveLabel(name string, value ...string) types.GomegaMatcher

HaveLabel succeeds if actual has a "Labels" field that contains a map key with the specified name and the optionally specified value.

Expect(container).To(HaveLabel("foobar"))
Expect(container).To(HaveLabel("foo", "bar"))

func WithFlavor

func WithFlavor(flavor string) types.GomegaMatcher

WithFlavor succeeds if actual has a Flavor field and the specified flavor matches this field.

func WithName

func WithName(nameid string) types.GomegaMatcher

WithName succeeds if actual has a Name field and optionally an ID field, and the specified nameid matches at least one of these fields.

func WithStrictType

func WithStrictType(typ string) types.GomegaMatcher

WithStrictType succeeds if actual has a Type field and the specified type matches it.

Expect(container).To(BeAContainer(WithStrictType("foo")))

func WithType

func WithType(typeflavor string) types.GomegaMatcher

WithType succeeds if actual has Type and Flavor fields and the specified typeflavor matches at least one of these fields.

Expect(container).To(BeAContainer(WithType("foo")))

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL