testsuite

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package testsuite provides test environment to run E2E and integration tests..

Index

Constants

View Source
const (
	VerificationTokenDuration = time.Second * 2
	APIKeyCacheDuration       = time.Second * 2

	APISrvPort   = "8080"
	AdminSrvPort = "8081"
)

Variables

This section is empty.

Functions

func Eventually

func Eventually(times uint64, interval time.Duration, f func() error) error

Eventually retries the given function n times, sleeping 1s between each invocation. To mark an error as retryable, wrap it in retry.RetryableError. Non-retryable errors return immediately.

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

APIClient is a test client for verification API.

func NewAPIClient

func NewAPIClient(addr, key string) (*APIClient, error)

NewAPIClient creates an API server test client.

func (*APIClient) GetCertificate

GetCertificate wraps the VerificationCertificate API call.

func (*APIClient) GetToken

GetToken wraps the VerifyCode API call.

type AdminClient

type AdminClient struct {
	// contains filtered or unexported fields
}

AdminClient is a test client for admin API.

func NewAdminClient

func NewAdminClient(addr, key string) (*AdminClient, error)

NewAdminClient creates an Admin API test client.

func (*AdminClient) IssueCode

IssueCode wraps the IssueCode API call.

type E2EConfig added in v0.17.1

type E2EConfig struct {
	APIServerURL string           `env:"E2E_APISERVER_URL"`
	AdminAPIURL  string           `env:"E2E_ADMINAPI_URL"`
	ProjectID    string           `env:"E2E_PROJECT_ID"`
	DBConfig     *database.Config `env:",prefix=E2E_"`
}

E2EConfig represents configurations to run server E2E tests.

func NewE2EConfig added in v0.17.1

func NewE2EConfig(tb testing.TB, ctx context.Context) *E2EConfig

NewE2EConfig returns a new E2E test config.

type E2ESuite

type E2ESuite struct {
	// contains filtered or unexported fields
}

E2ESuite contains E2E test configs and other useful data.

func NewE2ESuite

func NewE2ESuite(tb testing.TB, ctx context.Context) *E2ESuite

NewE2ESuite returns an E2E test suite.

func (*E2ESuite) NewAPIClient

func (s *E2ESuite) NewAPIClient(context.Context, testing.TB) (*APIClient, error)

NewAPIClient returns an API client.

func (*E2ESuite) NewAdminAPIClient

func (s *E2ESuite) NewAdminAPIClient(context.Context, testing.TB) (*AdminClient, error)

NewAdminAPIClient returns an admin API client.

type IntegrationSuite

type IntegrationSuite struct {
	// contains filtered or unexported fields
}

IntegrationSuite contains the integration test configs and other useful data.

func NewIntegrationSuite

func NewIntegrationSuite(tb testing.TB, ctx context.Context) *IntegrationSuite

NewIntegrationSuite creates a IntegrationSuite for integration tests.

func (*IntegrationSuite) NewAPIClient

func (s *IntegrationSuite) NewAPIClient(ctx context.Context, tb testing.TB) (*APIClient, error)

NewAPIClient runs an API Server and returns a corresponding client.

func (*IntegrationSuite) NewAdminAPIClient

func (s *IntegrationSuite) NewAdminAPIClient(ctx context.Context, tb testing.TB) (*AdminClient, error)

NewAdminAPIClient runs an Admin API Server and returns a corresponding client.

type IntegrationTestConfig added in v0.17.1

type IntegrationTestConfig struct {
	Observability *observability.Config
	DBConfig      *database.Config

	APISrvConfig      config.APIServerConfig
	AdminAPISrvConfig config.AdminAPIServerConfig
}

IntegrationTestConfig represents configurations to run server integration tests.

func NewIntegrationTestConfig added in v0.17.1

func NewIntegrationTestConfig(ctx context.Context, tb testing.TB) (*IntegrationTestConfig, *database.Database)

type TestSuite

type TestSuite interface {
	NewAdminAPIClient(ctx context.Context, tb testing.TB) (*AdminClient, error)
	NewAPIClient(ctx context.Context, tb testing.TB) (*APIClient, error)
}

func NewTestSuite

func NewTestSuite(tb testing.TB, ctx context.Context, isE2E bool) TestSuite

NewTestSuite returns environment specific test suite.

Jump to

Keyboard shortcuts

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