mock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2017 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StorageAPIVersion is the API version this mock server follows.
	StorageAPIVersion = "2017-06-01"
)

Variables

This section is empty.

Functions

func NewForwardTransport

func NewForwardTransport(target *url.URL, parent http.RoundTripper) http.RoundTripper

NewForwardTransport creates a round tripper which forwards requests to a given target's host. It also sends request a given parent round tripper. If the parent is not given, http.DefaultTransport will be used.

Types

type Container

type Container map[string]Object

Container represents a container stored in StorageServer.

type ForwardTransport

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

ForwardTransport is a http.RoundTripper which forwards requests to a given target URL's host.

func (*ForwardTransport) RoundTrip

func (r *ForwardTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip updates request URL's hosts to the target URL's ones, and then sends the request to the parent round tripper.

type Object

type Object struct {
	Body       string
	Properties storage.BlobProperties
	Metadata   map[string][]string
}

Object represents an object stored in StorageServer.

type StorageServer

type StorageServer struct {
	// Items hold blob items in this mock server. This is a map of which keys
	// represent container names and the associated value represents a container.
	Items map[string]Container
	// contains filtered or unexported fields
}

StorageServer provides a mocked server. See https://docs.microsoft.com/en-us/rest/api/storageservices/

func NewStorageServer

func NewStorageServer() (res *StorageServer)

NewStorageServer creates a new mock storage server.

func (*StorageServer) Close

func (s *StorageServer) Close()

Close closes the mock server.

func (*StorageServer) GetClient

func (s *StorageServer) GetClient() (cli storage.Client, err error)

GetClient returns a storage client which is forareded to this mock server.

func (*StorageServer) ServeHTTP

func (s *StorageServer) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP handles requests.

Jump to

Keyboard shortcuts

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