testutils

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const FakeTokenID = "fakeUUID"

FakeTokenID is a fake token for the Selectel VPC API.

Variables

This section is empty.

Functions

func CompareClients

func CompareClients(t *testing.T, expected, actual *selvpcclient.ServiceClient)

CompareClients compares two ServiceClients.

func HandleReqWithBody

func HandleReqWithBody(t *testing.T, opts *HandleReqOpts)

HandleReqWithBody provides the HTTP endpoint to test requests with body.

func HandleReqWithoutBody

func HandleReqWithoutBody(t *testing.T, opts *HandleReqOpts)

HandleReqWithoutBody provides the HTTP endpoint to test requests without body.

Types

type HandleReqOpts

type HandleReqOpts struct {
	// Mux represents HTTP Mux for a testing handler.
	Mux *http.ServeMux

	// URL represents handler's HTTP URL.
	URL string

	// RawResponse represents raw string HTTP response that needs to be returned
	// by the handler.
	RawResponse string

	// RawRequest represents raw string HTTP request that needs to be compared
	// with the actual request that will be provided by the caller.
	RawRequest string

	// Method contains HTTP method that needs to be compared against real method
	// provided by the caller.
	Method string

	// Status represents HTTP status that will be returned by the handler.
	Status int

	// CallFlag can be used to check if caller sent a request to a handler.
	CallFlag *bool
}

HandleReqOpts represents options for the testing utils package handlers.

type TestEnv

type TestEnv struct {
	Mux    *http.ServeMux
	Server *httptest.Server
	Client *selvpcclient.ServiceClient
}

TestEnv represents a testing environment for all resources.

func SetupTestEnv

func SetupTestEnv() *TestEnv

SetupTestEnv prepares the new testing environment.

func (*TestEnv) NewTestResellV2Client

func (testEnv *TestEnv) NewTestResellV2Client()

NewTestResellV2Client prepares a client for the Resell V2 API tests.

func (*TestEnv) TearDownTestEnv

func (testEnv *TestEnv) TearDownTestEnv()

TearDownTestEnv releases the testing environment.

type TestIdentityMgr

type TestIdentityMgr struct {
	ServerURL string
}

func (TestIdentityMgr) GetEndpointForRegion

func (mgr TestIdentityMgr) GetEndpointForRegion(region string) (string, error)

func (TestIdentityMgr) GetToken

func (mgr TestIdentityMgr) GetToken() (string, error)

type TestQuotasEnv

type TestQuotasEnv struct {
	Mux    *http.ServeMux
	Server *httptest.Server
	Client *quotamanager.QuotaRegionalClient
}

TestQuotasEnv represents a testing environment for quotas.

func SetupTestQuotasEnv

func SetupTestQuotasEnv() *TestQuotasEnv

SetupTestQuotasEnv prepares the new quotas testing environment.

func (*TestQuotasEnv) NewTestRegionalClient

func (testEnv *TestQuotasEnv) NewTestRegionalClient()

NewTestRegionalClient prepares a client for the quota V1 API tests.

func (*TestQuotasEnv) TearDownTestEnv

func (testEnv *TestQuotasEnv) TearDownTestEnv()

TearDownTestEnv releases the testing environment.

Jump to

Keyboard shortcuts

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