sakerhet

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SakerhetRunIntegrationTestsEnvVar      = "SAKERHET_RUN_INTEGRATION_TESTS"
	SakerhetIntegrationTestsTimeoutSeconds = "SAKERHET_INTEGRATION_TEST_TIMEOUT"
)

Variables

This section is empty.

Functions

func ExpectGCPMessagesInSub added in v0.0.9

func ExpectGCPMessagesInSub(ctx context.Context, client *pubsub.Client, subscriptionID string, expectedData [][]byte, timeToWait time.Duration) error

Receive messages for a given duration, which simplifies testing.

func GetIntegrationTestTimeout added in v0.0.3

func GetIntegrationTestTimeout() time.Duration

func GetOrCreateGCPTopic

func GetOrCreateGCPTopic(ctx context.Context, client *pubsub.Client, topicID string) (*pubsub.Topic, error)

func InitPostgreSQLSchema

func InitPostgreSQLSchema(ctx context.Context, db *pgxpool.Pool, schema []string) error

func PublishToGCPTopic

func PublishToGCPTopic(ctx context.Context, client *pubsub.Client, topic *pubsub.Topic, payload []byte) error

func ReadGCPMessagesInSub added in v0.0.9

func ReadGCPMessagesInSub(ctx context.Context, client *pubsub.Client, subscriptionID string, timeToWait time.Duration) ([][]byte, error)

Receive messages for a given duration, which simplifies testing.

func SeedPostgreSQLData

func SeedPostgreSQLData(ctx context.Context, db *pgxpool.Pool, query string, data [][]any) error

func SkipIntegrationTestsWhenUnitTesting

func SkipIntegrationTestsWhenUnitTesting(t *testing.T)

func SkipUnitTestsWhenIntegrationTesting

func SkipUnitTestsWhenIntegrationTesting(t *testing.T)

func TruncatePostgreSQLTable

func TruncatePostgreSQLTable(ctx context.Context, db *pgxpool.Pool, tables []string) error

func UnorderedEqual

func UnorderedEqual[T any](first, second []T) bool

Types

type GCPPubSubIntegrationTestParams

type GCPPubSubIntegrationTestParams struct {
	ProjectID      string
	TopicID        string
	SubscriptionID string
}

type GCPPubSubIntegrationTester

type GCPPubSubIntegrationTester struct {
	ProjectID      string
	TopicID        string
	SubscriptionID string
	PubSubURI      string
}

func (*GCPPubSubIntegrationTester) ContainerStart

func (*GCPPubSubIntegrationTester) ContainsWantedMessages

func (g *GCPPubSubIntegrationTester) ContainsWantedMessages(ctx context.Context, expectedData [][]byte) error

func (*GCPPubSubIntegrationTester) ContainsWantedMessagesInDuration added in v0.0.3

func (g *GCPPubSubIntegrationTester) ContainsWantedMessagesInDuration(ctx context.Context, expectedData [][]byte, timeToTimeout time.Duration) error

func (*GCPPubSubIntegrationTester) CreateClient

func (g *GCPPubSubIntegrationTester) CreateClient(ctx context.Context) (*pubsub.Client, error)

func (*GCPPubSubIntegrationTester) PublishData

func (g *GCPPubSubIntegrationTester) PublishData(ctx context.Context, wantedData []byte) error

func (*GCPPubSubIntegrationTester) ReadMessages added in v0.0.9

func (g *GCPPubSubIntegrationTester) ReadMessages(ctx context.Context) ([][]byte, error)

func (*GCPPubSubIntegrationTester) ReadMessagesInDuration added in v0.0.9

func (g *GCPPubSubIntegrationTester) ReadMessagesInDuration(ctx context.Context, timeToTimeout time.Duration) ([][]byte, error)

type HttpHeaderValuePair added in v0.0.3

type HttpHeaderValuePair struct {
	Header string
	Value  string
}

type HttpIntegrationTestSituation added in v0.0.3

type HttpIntegrationTestSituation struct {
	Request     *HttpIntegrationTestSituationRequest
	Expectation *HttpIntegrationTestSituationExpectation
	Timeout     time.Duration
}

func (HttpIntegrationTestSituation) SituationChecker added in v0.0.3

type HttpIntegrationTestSituationExpectation added in v0.0.3

type HttpIntegrationTestSituationExpectation struct {
	ResponseStatusCode int
	ResponseBody       []byte
}

type HttpIntegrationTestSituationRequest added in v0.0.3

type HttpIntegrationTestSituationRequest struct {
	RequestURL     string
	RequestMethod  string
	RequestHeaders []HttpHeaderValuePair
	RequestBody    []byte
}

type HttpIntegrationTestSituationResult added in v0.0.11

type HttpIntegrationTestSituationResult struct {
	ResponseStatusCode int
	ResponseBody       []byte
}

type PostgreSQLIntegrationTestExpectation

type PostgreSQLIntegrationTestExpectation struct {
	GetQuery       string
	ExpectedValues []any
}

type PostgreSQLIntegrationTestParams

type PostgreSQLIntegrationTestParams struct {
	User     string
	Password string
	DB       string
}

type PostgreSQLIntegrationTestSeed

type PostgreSQLIntegrationTestSeed struct {
	InsertQuery  string
	InsertValues [][]any
}

type PostgreSQLIntegrationTestSituation

type PostgreSQLIntegrationTestSituation struct {
	Seeds   []PostgreSQLIntegrationTestSeed
	Expects []PostgreSQLIntegrationTestExpectation
}

type PostgreSQLIntegrationTester

type PostgreSQLIntegrationTester struct {
	User     string
	Password string
	DB       string
}

func (*PostgreSQLIntegrationTester) CheckContainsExpectedData

func (p *PostgreSQLIntegrationTester) CheckContainsExpectedData(resultSet []any, expected []any) error

func (*PostgreSQLIntegrationTester) ContainerStart

func (*PostgreSQLIntegrationTester) FetchData

func (p *PostgreSQLIntegrationTester) FetchData(ctx context.Context, dbPool *pgxpool.Pool, query string, rowHandler func(rows pgx.Rows) (any, error)) ([]any, error)

func (*PostgreSQLIntegrationTester) InitSchema

func (p *PostgreSQLIntegrationTester) InitSchema(ctx context.Context, dbPool *pgxpool.Pool, initialSchema []string) error

func (*PostgreSQLIntegrationTester) SeedData

func (*PostgreSQLIntegrationTester) TruncateTable

func (p *PostgreSQLIntegrationTester) TruncateTable(ctx context.Context, dbPool *pgxpool.Pool, tables []string) error

type Sakerhet added in v0.1.0

type Sakerhet struct {
	GCPPubSubIntegrationTester  *GCPPubSubIntegrationTester
	PostgreSQLIntegrationTester *PostgreSQLIntegrationTester
}

func NewSakerhetIntegrationTest added in v0.1.0

func NewSakerhetIntegrationTest(sakerhetBuilder SakerhetBuilder) Sakerhet

Sakerhet Integration test smart constructor

type SakerhetBuilder added in v0.1.0

type SakerhetBuilder struct {
	GCPPubSub  *GCPPubSubIntegrationTestParams
	PostgreSQL *PostgreSQLIntegrationTestParams
}

Jump to

Keyboard shortcuts

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