preflight

package module
v0.0.7 Latest Latest
Warning

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

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

README

preflight

GoDoc Go Report Card

Documentation

Index

Constants

View Source
const (
	StatusGreen
	StatusYellow
	StatusRed
	StatusUnknown
)

statuses

Variables

This section is empty.

Functions

func ConvertStatusString added in v0.0.4

func ConvertStatusString(color string) int

ConvertStatusString converts a string ("red"/"yellow"/"green") into the status code.

Types

type Check

type Check interface {
	// Name should return a unique name for this check.
	Name() string
	// Check should execute the check and return a list of Results.
	Check(ctx context.Context) []Result
}

Check defines the interface all preflight checks must expose.

type CheckMock

type CheckMock struct {
	// CheckFunc mocks the Check method.
	CheckFunc func(ctx context.Context) []Result

	// NameFunc mocks the Name method.
	NameFunc func() string
	// contains filtered or unexported fields
}

CheckMock is a mock implementation of Check.

    func TestSomethingThatUsesCheck(t *testing.T) {

        // make and configure a mocked Check
        mockedCheck := &CheckMock{
            CheckFunc: func(ctx context.Context) []Result {
	               panic("mock out the Check method")
            },
            NameFunc: func() string {
	               panic("mock out the Name method")
            },
        }

        // use mockedCheck in code that requires Check
        // and then make assertions.

    }

func (*CheckMock) Check

func (mock *CheckMock) Check(ctx context.Context) []Result

Check calls CheckFunc.

func (*CheckMock) CheckCalls

func (mock *CheckMock) CheckCalls() []struct {
	Ctx context.Context
}

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

len(mockedCheck.CheckCalls())

func (*CheckMock) Name

func (mock *CheckMock) Name() string

Name calls NameFunc.

func (*CheckMock) NameCalls

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

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

len(mockedCheck.NameCalls())

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker executes multiple checks in parallel and returns the list of results.

func NewChecker

func NewChecker(opts ...Option) *Checker

NewChecker constructs a new Checker.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context) []Result

Check executes all of the checks and returns a sorted list of results.

type Option

type Option func(*options)

Option is a function for customizing the checker.

func WithCheck

func WithCheck(c Check) Option

WithCheck adds a Check to the Checker.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the Checker's timeout.

type Result

type Result struct {
	// Name is the name or short desription of the check.
	Name string `json:"name"`
	// Message is a status or error message.
	Message string `json:"message"`
	// Status represents the check's state: green/yellow/red.
	Status int `json:"status"`
}

Result represents the result of a check.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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