package
0.1.0
Repository: https://github.com/mattmoor/triggers.git
Documentation: pkg.go.dev

# README

Builder package for tests

This package holds Builder functions that can be used to create struct in tests with less noise.

One of the most important characteristic of a unit test (and any type of test really) is readability. This means it should be easy to read and clearly show the intent of the test. The setup (and cleanup) of the tests should be as small as possible to avoid the noise. Those builders exists to help with that.

There are two types of functions defined in this package:

*Builders*: Create and return a struct
*Modifiers*: Return a function that will operate on a given struct.
    // Definition
    type TriggerBindingOp func(*v1alpha1.TriggerBinding)
    // Builder
    func TriggerBinding(name, namespace string, ops ...TriggerBindingOp) *v1alpha1.TriggerBinding {
        // […]
    }
    // Modifier
    func TriggerBindingSpec(ops ...TriggerBindingSpecOp) TriggerBindingOp {
        // […]
    }

The main reason to define the Op type, and using it in the methods signatures is to group Modifier function together. It makes it easier to see what is a Modifier (or Builder) and on what it operates.

The go tests in this package exemplify the consolidation that can be achieved by using the builders:

# Functions

EventInterceptorParam adds a parameter to the EventInterceptor.
EventListener creates an EventListener with default values.
EventListenerAddress sets the EventListenerAddress on the EventListenerStatus.
EventListenerCondition sets the specified condition on the EventListenerStatus.
EventListenerConfig sets the EventListenerConfiguration on the EventListenerStatus.
EventListenerMeta sets the Meta structs of the EventListener.
EventListenerServiceAccount sets the specified ServiceAccount of the EventListener.
EventListenerSpec sets the specified spec of the EventListener.
EventListenerStatus sets the specified status of the EventListener.
EventListenerTrigger adds an EventListenerTrigger to the EventListenerSpec Triggers.
EventListenerTriggerInterceptor adds an objectRef to an interceptor Service to the EventListenerTrigger.
EventListenerTriggerName adds a Name to the Trigger in EventListenerSpec Triggers.
EventListenerTriggerParam adds a param to the EventListenerTrigger.
Label adds a single label to the ObjectMeta.
Trigger creates an EventListenerTrigger.
TriggerBinding creates a TriggerBinding with default values.
TriggerBindingMeta sets the Meta structs of the TriggerBinding.
TriggerBindingParam adds a param to the TriggerBindingSpec.
TriggerBindingSpec sets the specified spec of the TriggerBinding.
TriggerResourceTemplate adds a ResourceTemplate to the TriggerTemplateSpec.
TriggerTemplate creates a TriggerTemplate with default values.
TriggerTemplateMeta sets the Meta structs of the TriggerTemplate.
TriggerTemplateParam adds a ParamSpec to the TriggerTemplateSpec.
TriggerTemplateSpec sets the TriggerTemplateSpec.
TypeMeta sets the TypeMeta struct with default values.

# Interfaces

MetaOp is an interface that is used in other builders.

# Type aliases

EventInterceptorOp is an operation which modifies the EventInterceptor.
EventListenerOp is an operation which modifies the EventListener.
EventListenerSpecOp is an operation which modifies the EventListenerSpec.
EventListenerStatusOp is an operation which modifies the EventListenerStatus.
EventListenerTriggerOp is an operation which modifies the Trigger.
ObjectMetaOp is an operation which modifies the ObjectMeta.
TriggerBindingOp is an operation which modifies the TriggerBinding.
TriggerBindingSpecOp is an operation which modifies the TriggerBindingSpec.
TriggerTemplateOp is an operation which modifies an TriggerTemplate struct.
TriggerTemplateSpecOp is an operation which modifies a TriggerTemplateSpec struct.
TypeMetaOp is an operation which modifies the TypeMeta.