constraints

package
v1.14.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constraint

type Constraint interface {
	String() string
	Assert() error
}

Constraint represents a constraint that is to be evaluated

func AND

func AND(constraints []Constraint) Constraint

AND constructs a new constraint that is the logical AND of the supplied constraints

func New

func New(logger logger.Interface, requirements []string, properties map[string]Property) (Constraint, error)

New creates a new constraint for the supplied requirements and properties

func OR

func OR(constraints []Constraint) Constraint

OR constructs a new constrant that is the logical OR of the supplied constraints

type ConstraintMock

type ConstraintMock struct {
	// AssertFunc mocks the Assert method.
	AssertFunc func() error

	// StringFunc mocks the String method.
	StringFunc func() string
	// contains filtered or unexported fields
}

ConstraintMock is a mock implementation of Constraint.

func TestSomethingThatUsesConstraint(t *testing.T) {

	// make and configure a mocked Constraint
	mockedConstraint := &ConstraintMock{
		AssertFunc: func() error {
			panic("mock out the Assert method")
		},
		StringFunc: func() string {
			panic("mock out the String method")
		},
	}

	// use mockedConstraint in code that requires Constraint
	// and then make assertions.

}

func (*ConstraintMock) Assert

func (mock *ConstraintMock) Assert() error

Assert calls AssertFunc.

func (*ConstraintMock) AssertCalls

func (mock *ConstraintMock) AssertCalls() []struct {
}

AssertCalls gets all the calls that were made to Assert. Check the length with:

len(mockedConstraint.AssertCalls())

func (*ConstraintMock) String

func (mock *ConstraintMock) String() string

String calls StringFunc.

func (*ConstraintMock) StringCalls

func (mock *ConstraintMock) StringCalls() []struct {
}

StringCalls gets all the calls that were made to String. Check the length with:

len(mockedConstraint.StringCalls())

type Property

type Property interface {
	Name() string
	Value() (string, error)
	String() string
	CompareTo(string) (int, error)
	Validate(string) error
}

Property represents a property that is used to check requirements

func NewStringProperty

func NewStringProperty(name string, value string) Property

NewStringProperty creates a string property based on the name-value pair

func NewVersionProperty

func NewVersionProperty(name string, value string) Property

NewVersionProperty creates a property representing a semantic version based on the name-value pair

type PropertyMock

type PropertyMock struct {
	// CompareToFunc mocks the CompareTo method.
	CompareToFunc func(s string) (int, error)

	// NameFunc mocks the Name method.
	NameFunc func() string

	// StringFunc mocks the String method.
	StringFunc func() string

	// ValidateFunc mocks the Validate method.
	ValidateFunc func(s string) error

	// ValueFunc mocks the Value method.
	ValueFunc func() (string, error)
	// contains filtered or unexported fields
}

PropertyMock is a mock implementation of Property.

func TestSomethingThatUsesProperty(t *testing.T) {

	// make and configure a mocked Property
	mockedProperty := &PropertyMock{
		CompareToFunc: func(s string) (int, error) {
			panic("mock out the CompareTo method")
		},
		NameFunc: func() string {
			panic("mock out the Name method")
		},
		StringFunc: func() string {
			panic("mock out the String method")
		},
		ValidateFunc: func(s string) error {
			panic("mock out the Validate method")
		},
		ValueFunc: func() (string, error) {
			panic("mock out the Value method")
		},
	}

	// use mockedProperty in code that requires Property
	// and then make assertions.

}

func (*PropertyMock) CompareTo

func (mock *PropertyMock) CompareTo(s string) (int, error)

CompareTo calls CompareToFunc.

func (*PropertyMock) CompareToCalls

func (mock *PropertyMock) CompareToCalls() []struct {
	S string
}

CompareToCalls gets all the calls that were made to CompareTo. Check the length with:

len(mockedProperty.CompareToCalls())

func (*PropertyMock) Name

func (mock *PropertyMock) Name() string

Name calls NameFunc.

func (*PropertyMock) NameCalls

func (mock *PropertyMock) NameCalls() []struct {
}

NameCalls gets all the calls that were made to Name. Check the length with:

len(mockedProperty.NameCalls())

func (*PropertyMock) String

func (mock *PropertyMock) String() string

String calls StringFunc.

func (*PropertyMock) StringCalls

func (mock *PropertyMock) StringCalls() []struct {
}

StringCalls gets all the calls that were made to String. Check the length with:

len(mockedProperty.StringCalls())

func (*PropertyMock) Validate

func (mock *PropertyMock) Validate(s string) error

Validate calls ValidateFunc.

func (*PropertyMock) ValidateCalls

func (mock *PropertyMock) ValidateCalls() []struct {
	S string
}

ValidateCalls gets all the calls that were made to Validate. Check the length with:

len(mockedProperty.ValidateCalls())

func (*PropertyMock) Value

func (mock *PropertyMock) Value() (string, error)

Value calls ValueFunc.

func (*PropertyMock) ValueCalls

func (mock *PropertyMock) ValueCalls() []struct {
}

ValueCalls gets all the calls that were made to Value. Check the length with:

len(mockedProperty.ValueCalls())

Jump to

Keyboard shortcuts

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