testutil

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestClient

func CreateTestClient(t *testing.T) *interstellar.Client

CreateTestClient creates an *interstellar.Client for tests It gets the cosmos db connection string from the environment variable `AZURE_COSMOS_DB_CONNECTION_STRING` If the environment variable is not set, it will cause the test to be skipped. If the environment variable fails to parse, the test will fail.

func DebugLog

func DebugLog(t *testing.T, format string, v ...interface{})

DebugLog logs the message to the test logger if DEBUG_LOGGING=Y

func FormatJSON

func FormatJSON(data []byte) []byte

FormatJSON formats the input json with indentation

func NewTestLoggingRequester

func NewTestLoggingRequester(t *testing.T, r interstellar.Requester) interstellar.Requester

NewTestLoggingRequester creates a new TestLoggingRequester which will log if the environment variable "DEBUG_LOGGING=Y" is

func ReadFileBytes

func ReadFileBytes(t *testing.T, file string) []byte

ReadFileBytes reads the entire file, or calls t.Fatal if the file cannot be read

func ToJSON

func ToJSON(v interface{}) string

ToJSON marshals the input value to a JSON String

Types

type TestKey

type TestKey string

TestKey is a test authorizer which just sets the authorization header to whatever its value is

func (TestKey) Authorize

func (k TestKey) Authorize(r *http.Request, resourceType interstellar.ResourceType, resourceLink string) (*http.Request, error)

Authorize sets the authorization header on the request

type TestLoggingRequester

type TestLoggingRequester struct {
	T *testing.T
	interstellar.Requester
}

TestLoggingRequester is a requester which logs each http request/response to the test runner logger

func (TestLoggingRequester) Do

Do runs the request and logs the request and response dumps to the Test logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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