api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HelloHandler

func HelloHandler() http.HandlerFunc

HelloHandler returns function containing a simple hello world example of an api handler

Types

type API

type API struct {
	Router *mux.Router
	// contains filtered or unexported fields
}

API provides a struct to wrap the api around

func Setup

func Setup(ctx context.Context, vault VaultClienter, r *mux.Router, s3Uploaded S3Clienter) *API

Setup function sets up the api and returns an api

type HelloResponse

type HelloResponse struct {
	Message string `json:"message,omitempty"`
}

type S3Clienter added in v0.3.0

type S3Clienter interface {
	UploadPart(ctx context.Context, req *s3client.UploadPartRequest, payload []byte) error
	UploadPartWithPsk(ctx context.Context, req *s3client.UploadPartRequest, payload []byte, psk []byte) error
	CheckPartUploaded(ctx context.Context, req *s3client.UploadPartRequest) (bool, error)
	Checker(ctx context.Context, state *healthcheck.CheckState) error
}

S3Clienter defines the required method

type S3ClienterMock added in v0.3.0

type S3ClienterMock struct {
	// CheckPartUploadedFunc mocks the CheckPartUploaded method.
	CheckPartUploadedFunc func(ctx context.Context, req *s3client.UploadPartRequest) (bool, error)

	// CheckerFunc mocks the Checker method.
	CheckerFunc func(ctx context.Context, state *healthcheck.CheckState) error

	// UploadPartFunc mocks the UploadPart method.
	UploadPartFunc func(ctx context.Context, req *s3client.UploadPartRequest, payload []byte) error

	// UploadPartWithPskFunc mocks the UploadPartWithPsk method.
	UploadPartWithPskFunc func(ctx context.Context, req *s3client.UploadPartRequest, payload []byte, psk []byte) error
	// contains filtered or unexported fields
}

S3ClienterMock is a mock implementation of S3Clienter.

    func TestSomethingThatUsesS3Clienter(t *testing.T) {

        // make and configure a mocked S3Clienter
        mockedS3Clienter := &S3ClienterMock{
            CheckPartUploadedFunc: func(ctx context.Context, req *s3client.UploadPartRequest) (bool, error) {
	               panic("mock out the CheckPartUploaded method")
            },
            CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
	               panic("mock out the Checker method")
            },
            UploadPartFunc: func(ctx context.Context, req *s3client.UploadPartRequest, payload []byte) error {
	               panic("mock out the UploadPart method")
            },
            UploadPartWithPskFunc: func(ctx context.Context, req *s3client.UploadPartRequest, payload []byte, psk []byte) error {
	               panic("mock out the UploadPartWithPsk method")
            },
        }

        // use mockedS3Clienter in code that requires S3Clienter
        // and then make assertions.

    }

func (*S3ClienterMock) CheckPartUploaded added in v0.3.0

func (mock *S3ClienterMock) CheckPartUploaded(ctx context.Context, req *s3client.UploadPartRequest) (bool, error)

CheckPartUploaded calls CheckPartUploadedFunc.

func (*S3ClienterMock) CheckPartUploadedCalls added in v0.3.0

func (mock *S3ClienterMock) CheckPartUploadedCalls() []struct {
	Ctx context.Context
	Req *s3client.UploadPartRequest
}

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

len(mockedS3Clienter.CheckPartUploadedCalls())

func (*S3ClienterMock) Checker added in v0.3.0

func (mock *S3ClienterMock) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*S3ClienterMock) CheckerCalls added in v0.3.0

func (mock *S3ClienterMock) CheckerCalls() []struct {
	Ctx   context.Context
	State *healthcheck.CheckState
}

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

len(mockedS3Clienter.CheckerCalls())

func (*S3ClienterMock) UploadPart added in v0.3.0

func (mock *S3ClienterMock) UploadPart(ctx context.Context, req *s3client.UploadPartRequest, payload []byte) error

UploadPart calls UploadPartFunc.

func (*S3ClienterMock) UploadPartCalls added in v0.3.0

func (mock *S3ClienterMock) UploadPartCalls() []struct {
	Ctx     context.Context
	Req     *s3client.UploadPartRequest
	Payload []byte
}

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

len(mockedS3Clienter.UploadPartCalls())

func (*S3ClienterMock) UploadPartWithPsk added in v0.3.0

func (mock *S3ClienterMock) UploadPartWithPsk(ctx context.Context, req *s3client.UploadPartRequest, payload []byte, psk []byte) error

UploadPartWithPsk calls UploadPartWithPskFunc.

func (*S3ClienterMock) UploadPartWithPskCalls added in v0.3.0

func (mock *S3ClienterMock) UploadPartWithPskCalls() []struct {
	Ctx     context.Context
	Req     *s3client.UploadPartRequest
	Payload []byte
	Psk     []byte
}

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

len(mockedS3Clienter.UploadPartWithPskCalls())

type VaultClienter added in v0.3.0

type VaultClienter interface {
	ReadKey(path, key string) (string, error)
	WriteKey(path, key, value string) error
	Checker(ctx context.Context, state *healthcheck.CheckState) error
}

VaultClienter defines the required method

type VaultClienterMock added in v0.3.0

type VaultClienterMock struct {
	// CheckerFunc mocks the Checker method.
	CheckerFunc func(ctx context.Context, state *healthcheck.CheckState) error

	// ReadKeyFunc mocks the ReadKey method.
	ReadKeyFunc func(path string, key string) (string, error)

	// WriteKeyFunc mocks the WriteKey method.
	WriteKeyFunc func(path string, key string, value string) error
	// contains filtered or unexported fields
}

VaultClienterMock is a mock implementation of VaultClienter.

    func TestSomethingThatUsesVaultClienter(t *testing.T) {

        // make and configure a mocked VaultClienter
        mockedVaultClienter := &VaultClienterMock{
            CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
	               panic("mock out the Checker method")
            },
            ReadKeyFunc: func(path string, key string) (string, error) {
	               panic("mock out the ReadKey method")
            },
            WriteKeyFunc: func(path string, key string, value string) error {
	               panic("mock out the WriteKey method")
            },
        }

        // use mockedVaultClienter in code that requires VaultClienter
        // and then make assertions.

    }

func (*VaultClienterMock) Checker added in v0.3.0

func (mock *VaultClienterMock) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*VaultClienterMock) CheckerCalls added in v0.3.0

func (mock *VaultClienterMock) CheckerCalls() []struct {
	Ctx   context.Context
	State *healthcheck.CheckState
}

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

len(mockedVaultClienter.CheckerCalls())

func (*VaultClienterMock) ReadKey added in v0.3.0

func (mock *VaultClienterMock) ReadKey(path string, key string) (string, error)

ReadKey calls ReadKeyFunc.

func (*VaultClienterMock) ReadKeyCalls added in v0.3.0

func (mock *VaultClienterMock) ReadKeyCalls() []struct {
	Path string
	Key  string
}

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

len(mockedVaultClienter.ReadKeyCalls())

func (*VaultClienterMock) WriteKey added in v0.3.0

func (mock *VaultClienterMock) WriteKey(path string, key string, value string) error

WriteKey calls WriteKeyFunc.

func (*VaultClienterMock) WriteKeyCalls added in v0.3.0

func (mock *VaultClienterMock) WriteKeyCalls() []struct {
	Path  string
	Key   string
	Value string
}

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

len(mockedVaultClienter.WriteKeyCalls())

Jump to

Keyboard shortcuts

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