test

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(t *testing.T, actual interface{}, expected interface{})

AssertEqual asserts if two object are same type and equal value

func AssertIsError

func AssertIsError(t *testing.T, err error)

AssertIsError asserts if an error equals nil and and fails the test if its not

func AssertNotError

func AssertNotError(t *testing.T, err error)

AssertNotError asserts if an error equals nil or fails the test

func DecryptData

func DecryptData(data []byte) ([]byte, error)

DecryptData is a helper function for decrypting during testing

func EncryptData

func EncryptData(data []byte) ([]byte, error)

EncryptData is a helper function for encrypting during testing

Types

type KmsMock

type KmsMock struct {
	kmsiface.KMSAPI

	GenerateDataKeyCalledCount int
	DecryptCalledCount         int
}

KmsMock can be used to mock KMS during testing. Set up with a static key

func (*KmsMock) Decrypt

func (k *KmsMock) Decrypt(di *kms.DecryptInput) (*kms.DecryptOutput, error)

Decrypt mock

func (*KmsMock) GenerateDataKey

func (k *KmsMock) GenerateDataKey(gki *kms.GenerateDataKeyInput) (*kms.GenerateDataKeyOutput, error)

GenerateDataKey mock

type S3Mock

type S3Mock struct {
	s3iface.S3API

	PutObjectHandler            func(*s3.PutObjectInput) (*s3.PutObjectOutput, error)
	PutObjectHandlerCalledCount int

	GetObjectHandler            func(*s3.GetObjectInput) (*s3.GetObjectOutput, error)
	GetObjectHandlerCalledCount int
}

S3Mock can be used to mock S3 during testing. Inject your own handlers.

func (*S3Mock) GetObject

func (s *S3Mock) GetObject(goi *s3.GetObjectInput) (*s3.GetObjectOutput, error)

GetObject mocks S3 GetObject. Call the handler configured for the S3Mock object.

func (*S3Mock) PutObject

func (s *S3Mock) PutObject(poi *s3.PutObjectInput) (*s3.PutObjectOutput, error)

PutObject mocks S3 PutObject. Call the handler configured for the S3Mock object.

type SQSMock

type SQSMock struct {
	sqsiface.SQSAPI
	// contains filtered or unexported fields
}

SQSMock is used to mock SQS during testing. Does not behave exactly as SQS, but should be sufficient for testing and provides a few useful functions when testing. Such as waiting for messages to be deleted, waiting for received messages etc.

func NewSQSMock

func NewSQSMock(timeoutSec int64, chanBufferSize int64) *SQSMock

NewSQSMock returns a new SQSMock.

func (*SQSMock) ChangeMessageVisibility

func (sm *SQSMock) ChangeMessageVisibility(cmvi *sqs.ChangeMessageVisibilityInput) (*sqs.ChangeMessageVisibilityOutput, error)

ChangeMessageVisibility sends a request to change a messages visibility to the mock.

func (*SQSMock) CreateQueueIfNotExists

func (sm *SQSMock) CreateQueueIfNotExists(queueURL *string)

CreateQueueIfNotExists will create a queue representation on the mock if one with the same name doesnt already exist.

func (*SQSMock) DeleteMessage

func (sm *SQSMock) DeleteMessage(dmi *sqs.DeleteMessageInput) (*sqs.DeleteMessageOutput, error)

DeleteMessage sends a delete message request to the mock.

func (*SQSMock) GetQueueUrl

func (sm *SQSMock) GetQueueUrl(gqui *sqs.GetQueueUrlInput) (*sqs.GetQueueUrlOutput, error)

GetQueueUrl is primarily implemented so the client can resolve the queues in the mock. Ignore lint output for this function. Cant rename it because its part of an interface which is defined elsewhere.

func (*SQSMock) ReceiveMessage

func (sm *SQSMock) ReceiveMessage(rmi *sqs.ReceiveMessageInput) (*sqs.ReceiveMessageOutput, error)

ReceiveMessage receives a message from the mock.

func (*SQSMock) SendMessage

func (sm *SQSMock) SendMessage(smi *sqs.SendMessageInput) (*sqs.SendMessageOutput, error)

SendMessage sends a message to the mock.

func (*SQSMock) SendMessageBatch

func (sm *SQSMock) SendMessageBatch(sbi *sqs.SendMessageBatchInput) (*sqs.SendMessageBatchOutput, error)

SendMessageBatch sends a batch to the mock.

func (*SQSMock) WaitUntilMessageDeleted

func (sm *SQSMock) WaitUntilMessageDeleted(queueURL *string, count int) error

WaitUntilMessageDeleted will wait until count delete message requests are received by the mock. Will time out after a configurable amount of time and return an error.

func (*SQSMock) WaitUntilMessagesReceived

func (sm *SQSMock) WaitUntilMessagesReceived(queueURL *string, count int) ([]*sqs.Message, error)

WaitUntilMessagesReceived waits until count messages are received and returns the received messages. Will time out after a configurable amount of time and return an error.

Jump to

Keyboard shortcuts

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