testutils

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: AGPL-3.0 Imports: 22 Imported by: 0

README

testutils

This provides some convenience methods for writing integration tests.

Functions

  • ClearDynamoTable(awsSession, tableName string) - Delete all items in a DynamoDB table
  • ClearS3Bucket(awsSession, bucketName string) - Delete all object versions in an S3 bucket

Example Integration Test

package main

import (
    "flag"
    "os"
    "testing"

    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/stretchr/testify/require"

    "github.com/panther-labs/panther/pkg/testutils"
)

var (
    awsSession      = session.Must(session.NewSession())
    integrationFlag = flag.Bool("integration", false, "run integration tests")
)

func TestMain(m *testing.M) {
    flag.Parse()
    os.Exit(m.Run())
}

func TestIntegrationAPI(t *testing.T) {
    if !*integrationFlag {
        t.Skip()
    }

    // Reset backend state - erase dynamo table and S3 bucket
    require.NoError(t, testutils.ClearDynamoTable(awsSession, "panther-rules-table"))
    require.NoError(t, testutils.ClearS3Bucket(awsSession, "panther-rules-bucket"))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDynamoTable

func ClearDynamoTable(awsSession *session.Session, tableName string) error

ClearDynamoTable deletes all items from the table.

Automatic table backups are not affected.

func ClearS3Bucket

func ClearS3Bucket(awsSession *session.Session, bucketName string) error

ClearS3Bucket deletes all object versions from the bucket.

Types

type AthenaMock added in v1.4.0

type AthenaMock struct {
	athenaiface.AthenaAPI
	mock.Mock
}

func (*AthenaMock) GetQueryExecution added in v1.4.0

func (*AthenaMock) GetQueryResults added in v1.4.0

func (*AthenaMock) StartQueryExecution added in v1.4.0

type DynamoDBMock added in v1.1.0

type DynamoDBMock struct {
	dynamodbiface.DynamoDBAPI
	mock.Mock
}

func (*DynamoDBMock) DeleteItem added in v1.3.0

func (*DynamoDBMock) GetItem added in v1.3.0

func (*DynamoDBMock) PutItem added in v1.1.0

func (*DynamoDBMock) Scan added in v1.3.0

func (*DynamoDBMock) UpdateItem added in v1.1.0

type EventBridgeMock added in v1.3.0

type EventBridgeMock struct {
	eventbridgeiface.EventBridgeAPI
	mock.Mock
}

func (*EventBridgeMock) DeleteRule added in v1.3.0

func (*EventBridgeMock) ListEventBuses added in v1.3.0

func (*EventBridgeMock) PutRule added in v1.3.0

func (*EventBridgeMock) PutTargets added in v1.3.0

func (*EventBridgeMock) RemoveTargets added in v1.3.0

type GlueMock added in v1.2.0

type GlueMock struct {
	glueiface.GlueAPI
	mock.Mock
}

func (*GlueMock) CreatePartition added in v1.2.0

func (m *GlueMock) CreatePartition(input *glue.CreatePartitionInput) (*glue.CreatePartitionOutput, error)

func (*GlueMock) CreateTable added in v1.4.0

func (m *GlueMock) CreateTable(input *glue.CreateTableInput) (*glue.CreateTableOutput, error)

func (*GlueMock) DeleteTable added in v1.2.0

func (m *GlueMock) DeleteTable(input *glue.DeleteTableInput) (*glue.DeleteTableOutput, error)

func (*GlueMock) GetPartition added in v1.2.0

func (m *GlueMock) GetPartition(input *glue.GetPartitionInput) (*glue.GetPartitionOutput, error)

func (*GlueMock) GetPartitions added in v1.3.0

func (m *GlueMock) GetPartitions(input *glue.GetPartitionsInput) (*glue.GetPartitionsOutput, error)

func (*GlueMock) GetTable added in v1.2.0

func (m *GlueMock) GetTable(input *glue.GetTableInput) (*glue.GetTableOutput, error)

func (*GlueMock) UpdatePartition added in v1.2.0

func (m *GlueMock) UpdatePartition(input *glue.UpdatePartitionInput) (*glue.UpdatePartitionOutput, error)

type LambdaMock added in v1.0.0

type LambdaMock struct {
	lambdaiface.LambdaAPI
	mock.Mock
}

func (*LambdaMock) Invoke added in v1.0.0

func (m *LambdaMock) Invoke(input *lambda.InvokeInput) (*lambda.InvokeOutput, error)

type S3Mock added in v1.0.0

type S3Mock struct {
	s3iface.S3API
	mock.Mock
}

func (*S3Mock) GetBucketLocation added in v1.0.0

func (m *S3Mock) GetBucketLocation(input *s3.GetBucketLocationInput) (*s3.GetBucketLocationOutput, error)

func (*S3Mock) GetObject added in v1.0.0

func (m *S3Mock) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error)

func (*S3Mock) ListObjectsV2Pages added in v1.3.0

func (m *S3Mock) ListObjectsV2Pages(input *s3.ListObjectsV2Input, f func(page *s3.ListObjectsV2Output, morePages bool) bool) error

type S3UploaderMock added in v1.3.0

type S3UploaderMock struct {
	s3manageriface.UploaderAPI
	mock.Mock
}

func (*S3UploaderMock) Upload added in v1.3.0

type SqsMock added in v1.1.0

type SqsMock struct {
	sqsiface.SQSAPI
	mock.Mock
}

func (*SqsMock) DeleteMessageBatch added in v1.2.0

func (m *SqsMock) DeleteMessageBatch(input *sqs.DeleteMessageBatchInput) (*sqs.DeleteMessageBatchOutput, error)

func (*SqsMock) GetQueueAttributes added in v1.2.0

func (m *SqsMock) GetQueueAttributes(input *sqs.GetQueueAttributesInput) (*sqs.GetQueueAttributesOutput, error)

func (*SqsMock) ReceiveMessage added in v1.2.0

func (m *SqsMock) ReceiveMessage(input *sqs.ReceiveMessageInput) (*sqs.ReceiveMessageOutput, error)

func (*SqsMock) SendMessage added in v1.1.0

func (m *SqsMock) SendMessage(input *sqs.SendMessageInput) (*sqs.SendMessageOutput, error)

func (*SqsMock) SendMessageBatch added in v1.2.0

func (m *SqsMock) SendMessageBatch(input *sqs.SendMessageBatchInput) (*sqs.SendMessageBatchOutput, error)

func (*SqsMock) SetQueueAttributes added in v1.3.0

func (m *SqsMock) SetQueueAttributes(input *sqs.SetQueueAttributesInput) (*sqs.SetQueueAttributesOutput, error)

Jump to

Keyboard shortcuts

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