go-selvpcclient: github.com/selectel/go-selvpcclient/selvpcclient/testutils Index | Files

package testutils

import "github.com/selectel/go-selvpcclient/selvpcclient/testutils"


Package Files

clients.go environment.go fakes.go handlers.go


const FakeTokenID = "fakeUUID"

FakeTokenID is a fake token for the Selectel VPC API.

func CompareClients Uses

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

CompareClients compares two ServiceClients.

func HandleReqWithBody Uses

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

HandleReqWithBody provides the HTTP endpoint to test requests with body.

func HandleReqWithoutBody Uses

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

HandleReqWithoutBody provides the HTTP endpoint to test requests without body.

type HandleReqOpts Uses

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 Uses

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

TestEnv represents a testing environment for all resources.

func SetupTestEnv Uses

func SetupTestEnv() *TestEnv

SetupTestEnv prepares the new testing environment.

func (*TestEnv) NewTestResellV2Client Uses

func (testEnv *TestEnv) NewTestResellV2Client()

NewTestResellV2Client prepares a client for the Resell V2 API tests.

func (*TestEnv) TearDownTestEnv Uses

func (testEnv *TestEnv) TearDownTestEnv()

TearDownTestEnv releases the testing environment.

Package testutils imports 9 packages (graph). Updated 2020-08-04. Refresh now. Tools for package owners.