testtool

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAsyncResponse added in v0.5.0

func CreateAsyncResponse() (string, []byte)

func GenReqID added in v0.6.1

func GenReqID() string

func MustParseIPNet

func MustParseIPNet(str string) *types.IPNet

for testing.

func TestAddItem added in v0.5.0

func TestAddItem(s api.CountableListSpec, validData interface{})

func TestClearItems added in v0.5.0

func TestClearItems(s api.CountableListSpec)

func TestDeepCopyObject added in v0.5.0

func TestDeepCopyObject(s api.Object, nilSpec api.Object)

for api.Object

func TestGetGroup added in v0.5.0

func TestGetGroup(s api.Spec, name string)

func TestGetItems added in v0.5.0

func TestGetItems(s api.ListSpec, items interface{})

List Spec

func TestGetMaxLimit added in v0.5.0

func TestGetMaxLimit(s api.CountableListSpec, limit int32)

api.CountableListSpec

func TestGetName added in v0.5.0

func TestGetName(s api.Spec, name string)

func TestGetPathMethod added in v0.5.0

func TestGetPathMethod(spec api.Spec, action api.Action, matchMethod string, matchPath string)

for api.Spec

func TestGetPathMethodForCountableList added in v0.5.0

func TestGetPathMethodForCountableList(spec api.CountableListSpec, listPath string)

func TestGetPathMethodForList added in v0.5.0

func TestGetPathMethodForList(spec api.ListSpec, listPath string)

func TestGetPathMethodForSpec added in v0.5.0

func TestGetPathMethodForSpec(spec api.Spec, createPath, getPath string)

func TestLen added in v0.5.0

func TestLen(s api.ListSpec, num int)

Types

type ResponseSpec

type ResponseSpec struct {
	Code int
	Spec api.Spec
	Err  *api.BadResponse
}

type TestClient added in v0.5.0

type TestClient struct {
	Client         api.ClientInterface
	Transport      *httpmock.MockTransport
	RequestHeaders map[string]http.Header
	RequestBody    map[string]string

	ReadFunc         func(s api.Spec) (requestID string, err error)
	ListFunc         func(s api.ListSpec, keywords api.SearchParams) (requestID string, err error)
	ListAllFunc      func(s api.CountableListSpec, keywords api.SearchParams) (requestID string, err error)
	CountFunc        func(s api.CountableListSpec, keywords api.SearchParams) (requestID string, err error)
	UpdateFunc       func(s api.Spec, body interface{}) (requestID string, err error)
	CreateFunc       func(s api.Spec, body interface{}) (requestID string, err error)
	ApplyFunc        func(s api.Spec, body interface{}) (requestID string, err error)
	DeleteFunc       func(s api.Spec) (requestID string, err error)
	CancelFunc       func(s api.Spec) (requestID string, err error)
	WatchReadFunc    func(ctx context.Context, interval time.Duration, s api.Spec) error
	WatchListFunc    func(ctx context.Context, interval time.Duration, s api.ListSpec, keyword api.SearchParams) error
	WatchListAllFunc func(ctx context.Context, interval time.Duration, s api.CountableListSpec, keyword api.SearchParams) error
}

func NewTestClient added in v0.5.0

func NewTestClient(token, endpoint string, logger api.Logger) *TestClient

func (*TestClient) Apply added in v0.5.0

func (n *TestClient) Apply(ctx context.Context, s api.Spec, body interface{}) (string, error)

func (*TestClient) Cancel added in v0.5.0

func (n *TestClient) Cancel(ctx context.Context, s api.Spec) (string, error)

func (*TestClient) Count added in v0.5.0

func (n *TestClient) Count(ctx context.Context, s api.CountableListSpec, keywords api.SearchParams) (string, error)

func (*TestClient) Create added in v0.5.0

func (n *TestClient) Create(ctx context.Context, s api.Spec, body interface{}) (string, error)

func (*TestClient) Delete added in v0.5.0

func (n *TestClient) Delete(ctx context.Context, s api.Spec) (string, error)

func (*TestClient) List added in v0.5.0

func (n *TestClient) List(ctx context.Context, s api.ListSpec, keywords api.SearchParams) (string, error)

func (*TestClient) ListAll added in v0.5.0

func (n *TestClient) ListAll(ctx context.Context, s api.CountableListSpec, keywords api.SearchParams) (string, error)

func (*TestClient) Read added in v0.5.0

func (n *TestClient) Read(ctx context.Context, s api.Spec) (string, error)

func (*TestClient) RoundTrip added in v0.5.0

func (n *TestClient) RoundTrip(req *http.Request) (*http.Response, error)

func (*TestClient) SetRoundTripper added in v0.9.0

func (n *TestClient) SetRoundTripper(rt http.RoundTripper)

func (*TestClient) Update added in v0.5.0

func (n *TestClient) Update(ctx context.Context, s api.Spec, body interface{}) (string, error)

func (*TestClient) WatchList added in v0.5.0

func (n *TestClient) WatchList(ctx context.Context, interval time.Duration, s api.ListSpec, keyword api.SearchParams) error

func (*TestClient) WatchListAll added in v0.5.0

func (n *TestClient) WatchListAll(ctx context.Context, interval time.Duration, s api.CountableListSpec, keyword api.SearchParams) error

func (*TestClient) WatchRead added in v0.5.0

func (n *TestClient) WatchRead(ctx context.Context, interval time.Duration, s api.Spec) error

type TestSpec added in v0.5.0

type TestSpec struct {
	ID     string `read:"id"`
	Name   string `read:"name" update:"name" create:"name" apply:"name"`
	Number int64  `read:"number" update:"number" create:"number" apply:"number"`
}

func (*TestSpec) DeepCopyObject added in v0.5.0

func (t *TestSpec) DeepCopyObject() api.Object

func (*TestSpec) DeepCopyTestSpec added in v0.5.0

func (t *TestSpec) DeepCopyTestSpec() *TestSpec

func (*TestSpec) GetGroup added in v0.5.0

func (t *TestSpec) GetGroup() string

func (*TestSpec) GetName added in v0.5.0

func (t *TestSpec) GetName() string

func (*TestSpec) GetPathMethod added in v0.5.0

func (t *TestSpec) GetPathMethod(action api.Action) (string, string)

func (*TestSpec) SetPathParams added in v0.6.0

func (t *TestSpec) SetPathParams(args ...interface{}) error

type TestSpecCountableList added in v0.5.0

type TestSpecCountableList struct {
	api.Count
	TestSpecList
}

func (*TestSpecCountableList) DeepCopyObject added in v0.5.0

func (t *TestSpecCountableList) DeepCopyObject() api.Object

func (*TestSpecCountableList) GetPathMethod added in v0.5.0

func (t *TestSpecCountableList) GetPathMethod(action api.Action) (string, string)

type TestSpecList added in v0.5.0

type TestSpecList struct {
	Items []TestSpec `read:"items"`
}

func (*TestSpecList) AddItem added in v0.5.0

func (c *TestSpecList) AddItem(v interface{}) bool

func (*TestSpecList) ClearItems added in v0.5.0

func (c *TestSpecList) ClearItems()

func (*TestSpecList) DeepCopyObject added in v0.5.0

func (t *TestSpecList) DeepCopyObject() api.Object

func (*TestSpecList) GetGroup added in v0.5.0

func (t *TestSpecList) GetGroup() string

func (*TestSpecList) GetItems added in v0.5.0

func (t *TestSpecList) GetItems() interface{}

func (*TestSpecList) GetMaxLimit added in v0.5.0

func (c *TestSpecList) GetMaxLimit() int32

func (*TestSpecList) GetName added in v0.5.0

func (t *TestSpecList) GetName() string

func (*TestSpecList) GetPathMethod added in v0.5.0

func (t *TestSpecList) GetPathMethod(action api.Action) (string, string)

func (*TestSpecList) Index added in v0.5.0

func (c *TestSpecList) Index(i int) interface{}

func (*TestSpecList) Init added in v0.5.0

func (t *TestSpecList) Init()

func (*TestSpecList) Len added in v0.5.0

func (c *TestSpecList) Len() int

func (*TestSpecList) SetPathParams added in v0.6.0

func (t *TestSpecList) SetPathParams(args ...interface{}) error

Jump to

Keyboard shortcuts

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