filetest

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UploaderMock

type UploaderMock struct {
	// BucketNameFunc mocks the BucketName method.
	BucketNameFunc func() string

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

	// SessionFunc mocks the Session method.
	SessionFunc func() *session.Session

	// UploadFunc mocks the Upload method.
	UploadFunc func(input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)

	// UploadWithPSKFunc mocks the UploadWithPSK method.
	UploadWithPSKFunc func(input *s3manager.UploadInput, psk []byte) (*s3manager.UploadOutput, error)
	// contains filtered or unexported fields
}

UploaderMock is a mock implementation of file.Uploader.

func TestSomethingThatUsesUploader(t *testing.T) {

	// make and configure a mocked file.Uploader
	mockedUploader := &UploaderMock{
		BucketNameFunc: func() string {
			panic("mock out the BucketName method")
		},
		CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		SessionFunc: func() *session.Session {
			panic("mock out the Session method")
		},
		UploadFunc: func(input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error) {
			panic("mock out the Upload method")
		},
		UploadWithPSKFunc: func(input *s3manager.UploadInput, psk []byte) (*s3manager.UploadOutput, error) {
			panic("mock out the UploadWithPSK method")
		},
	}

	// use mockedUploader in code that requires file.Uploader
	// and then make assertions.

}

func (*UploaderMock) BucketName

func (mock *UploaderMock) BucketName() string

BucketName calls BucketNameFunc.

func (*UploaderMock) BucketNameCalls

func (mock *UploaderMock) BucketNameCalls() []struct {
}

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

len(mockedUploader.BucketNameCalls())

func (*UploaderMock) Checker

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

Checker calls CheckerFunc.

func (*UploaderMock) CheckerCalls

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

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

len(mockedUploader.CheckerCalls())

func (*UploaderMock) Session

func (mock *UploaderMock) Session() *session.Session

Session calls SessionFunc.

func (*UploaderMock) SessionCalls

func (mock *UploaderMock) SessionCalls() []struct {
}

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

len(mockedUploader.SessionCalls())

func (*UploaderMock) Upload

func (mock *UploaderMock) Upload(input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)

Upload calls UploadFunc.

func (*UploaderMock) UploadCalls

func (mock *UploaderMock) UploadCalls() []struct {
	Input   *s3manager.UploadInput
	Options []func(*s3manager.Uploader)
}

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

len(mockedUploader.UploadCalls())

func (*UploaderMock) UploadWithPSK

func (mock *UploaderMock) UploadWithPSK(input *s3manager.UploadInput, psk []byte) (*s3manager.UploadOutput, error)

UploadWithPSK calls UploadWithPSKFunc.

func (*UploaderMock) UploadWithPSKCalls

func (mock *UploaderMock) UploadWithPSKCalls() []struct {
	Input *s3manager.UploadInput
	Psk   []byte
}

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

len(mockedUploader.UploadWithPSKCalls())

type VaultClientMock

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

VaultClientMock is a mock implementation of file.VaultClient.

func TestSomethingThatUsesVaultClient(t *testing.T) {

	// make and configure a mocked file.VaultClient
	mockedVaultClient := &VaultClientMock{
		WriteKeyFunc: func(path string, key string, value string) error {
			panic("mock out the WriteKey method")
		},
	}

	// use mockedVaultClient in code that requires file.VaultClient
	// and then make assertions.

}

func (*VaultClientMock) WriteKey

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

WriteKey calls WriteKeyFunc.

func (*VaultClientMock) WriteKeyCalls

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

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

len(mockedVaultClient.WriteKeyCalls())

Jump to

Keyboard shortcuts

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