Documentation ¶
Index ¶
- Constants
- func CreateNamespace(ctx context.Context, baseName string) (*v1.Namespace, error)
- func DeleteNamespace(ns *v1.Namespace) error
- func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectEmpty(actual interface{}, explain ...interface{})
- func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectError(err error, explain ...interface{})
- func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
- type AuthUser
- type Framework
- type HttpHelper
- func (h *HttpHelper) AuthToken() *HttpHelper
- func (h *HttpHelper) Delete(urlVal string) http.Request
- func (h *HttpHelper) FormatUrl(url string) string
- func (h *HttpHelper) Get(urlVal string, header map[string]string) http.Request
- func (h *HttpHelper) GetToken(user *AuthUser) error
- func (h *HttpHelper) Login() *HttpHelper
- func (h *HttpHelper) LoginByUser(user *AuthUser) error
- func (h *HttpHelper) MultiUserRequest(method, url, body string, header map[string]string) map[string]MultiRequestResponse
- func (h *HttpHelper) Post(urlVal, body string, header map[string]string) http.Request
- func (h *HttpHelper) Put(urlVal, body string, header map[string]string) http.Request
- func (h *HttpHelper) Request(method, urlVal, data string, header map[string]string) http.Request
- func (h *HttpHelper) RequestByUser(method, urlVal, data string, header map[string]string, user string) http.Request
- type MultiRequestResponse
- type TimeoutContext
Constants ¶
const ( WaitInterval = 2 * time.Second WaitTimeout = 120 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func CreateNamespace ¶
Create namespace
func ExpectConsistOf ¶
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
func ExpectEmpty ¶
func ExpectEmpty(actual interface{}, explain ...interface{})
ExpectEmpty expects actual is empty
func ExpectEqual ¶
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectEqual expects the specified two are the same, otherwise an exception raises
func ExpectError ¶
func ExpectError(err error, explain ...interface{})
ExpectError expects an error happens, otherwise an exception raises
func ExpectHaveKey ¶
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
ExpectHaveKey expects the actual map has the key in the keyset
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
func ExpectNoErrorWithOffset ¶
ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
func ExpectNotEqual ¶
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
Types ¶
type Framework ¶
type Framework struct { BaseName string // Http client Host string HttpHelper *HttpHelper // Timeouts contains the custom timeouts used during the test execution. Timeouts *TimeoutContext // preset tenant/project/namespace TenantName string ProjectName string Namespace string }
Framework supports common operations used by e2e tests; it will keep a client & a namespace for you.
func NewDefaultFramework ¶
NewFramework creates a test framework and sets up a BeforeEach/AfterEach for you (you can write additional before/after each functions).
func NewFramework ¶
type HttpHelper ¶
type HttpHelper struct { HostPath string Admin AuthUser TenantAdmin AuthUser ProjectAdmin AuthUser User AuthUser Client http.Client }
func NewHttpHelper ¶
func NewHttpHelper() *HttpHelper
func (*HttpHelper) GetToken ¶
func (h *HttpHelper) GetToken(user *AuthUser) error
get token by ak sk
func (*HttpHelper) Login ¶
func (h *HttpHelper) Login() *HttpHelper
func (*HttpHelper) LoginByUser ¶
func (h *HttpHelper) LoginByUser(user *AuthUser) error
func (*HttpHelper) MultiUserRequest ¶
func (h *HttpHelper) MultiUserRequest(method, url, body string, header map[string]string) map[string]MultiRequestResponse
multi user request test
func (*HttpHelper) RequestByUser ¶
func (h *HttpHelper) RequestByUser(method, urlVal, data string, header map[string]string, user string) http.Request
request by admin\tenantAdmin\projectAdmin\user
type MultiRequestResponse ¶
type TimeoutContext ¶
type TimeoutContext struct { // HttpRequest is how long to wait for the http request HttpRequest time.Duration // ResourceCreate is how long to wait for resource creation // Use it in case create fail and hold WaitInterval time.Duration // ResourceCreate is how long to wait for resource delete // Use it in case delete fail and hold WaitTimeout time.Duration }
TimeoutContext contains timeout settings for several actions.
func NewTimeoutContextWithDefaults ¶
func NewTimeoutContextWithDefaults() *TimeoutContext
NewTimeoutContextWithDefaults returns a TimeoutContext with default values.