test

package
v1.5.2-RC1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(path string) (string, error)

GenerateKey generates aes key

func GetDefaultConfigMap

func GetDefaultConfigMap() map[string]interface{}

GetDefaultConfigMap returns the defailt config map for easier modification.

func Handler

func Handler(resp *Response) func(http.ResponseWriter, *http.Request)

Handler returns a handler function which handle requst according to the response provided

func InitDatabaseFromEnv

func InitDatabaseFromEnv()

InitDatabaseFromEnv is used to initialize database for testing

func NewAdminserver

func NewAdminserver(config map[string]interface{}) (*httptest.Server, error)

NewAdminserver returns a mock admin server

func NewCapacityHandle

func NewCapacityHandle() (func(http.ResponseWriter, *http.Request), error)

NewCapacityHandle ...

func NewServer

func NewServer(mappings ...*RequestHandlerMapping) *httptest.Server

NewServer creates a HTTP server for unit test

Types

type FakePolicyManager

type FakePolicyManager struct {
}

func (*FakePolicyManager) CreatePolicy

func (f *FakePolicyManager) CreatePolicy(policy models.ReplicationPolicy) (int64, error)

func (*FakePolicyManager) GetPolicies

func (*FakePolicyManager) GetPolicy

func (*FakePolicyManager) RemovePolicy

func (f *FakePolicyManager) RemovePolicy(int64) error

func (*FakePolicyManager) UpdatePolicy

type FakeReplicatoinController

type FakeReplicatoinController struct {
	FakePolicyManager
}

func (*FakeReplicatoinController) Init

func (f *FakeReplicatoinController) Init() error

func (*FakeReplicatoinController) Replicate

func (f *FakeReplicatoinController) Replicate(policyID int64, metadata ...map[string]interface{}) error

type FakeWatchItemDAO

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

FakeWatchItemDAO is the fake implement for the dao.WatchItemDAO

func (*FakeWatchItemDAO) Add

func (f *FakeWatchItemDAO) Add(item *models.WatchItem) (int64, error)

Add ...

func (*FakeWatchItemDAO) DeleteByPolicyID

func (f *FakeWatchItemDAO) DeleteByPolicyID(policyID int64) error

DeleteByPolicyID : delete the WatchItem specified by policy ID

func (*FakeWatchItemDAO) Get

func (f *FakeWatchItemDAO) Get(namespace, operation string) ([]models.WatchItem, error)

Get returns WatchItem list according to the namespace and operation

type RequestHandlerMapping

type RequestHandlerMapping struct {
	// Method is the method the request used
	Method string
	// Pattern is the pattern the request must match
	Pattern string
	// Handler is the handler which handles the request
	Handler func(http.ResponseWriter, *http.Request)
}

RequestHandlerMapping is a mapping between request and its handler

func (*RequestHandlerMapping) ServeHTTP

func (rhm *RequestHandlerMapping) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP ...

type Response

type Response struct {
	// StatusCode is the status code of the response
	StatusCode int
	// Headers are the headers of the response
	Headers map[string]string
	// Boby is the body of the response
	Body []byte
}

Response is a response used for unit test

Jump to

Keyboard shortcuts

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