util_test

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGitRoot

func GetGitRoot() (string, error)

GetGitRoot gets the git root of this project.

func JsonEqual

func JsonEqual(t *testing.T, expected, actual []byte)

JsonEqual assert two json are equal

func MustDecodeHex

func MustDecodeHex(t *testing.T, str string) []byte

func MustGitPath

func MustGitPath(relative string) string

MustGitPath is util for getting relative path to git root

Types

type Req

type Req struct {
	BodyArr   []byte
	HeaderMap map[string]string
	CookieMap map[string]string
	QueryMap  map[string]string
	ParamMap  map[string]string
	MethodStr string
	PathStr   string
	HostStr   string
	UriStr    string
}

Req is a zero value useful request object

func (Req) GetBody

func (r Req) GetBody() []byte

func (Req) GetCookie

func (r Req) GetCookie(k string) string

func (Req) GetHeader

func (r Req) GetHeader(k string) string

func (Req) GetHost

func (r Req) GetHost() string

func (Req) GetMapBody

func (r Req) GetMapBody(key string) string

func (Req) GetMethod

func (r Req) GetMethod() string

func (Req) GetParam

func (r Req) GetParam(k string) string

func (Req) GetPath

func (r Req) GetPath() string

func (Req) GetPostForm

func (r Req) GetPostForm(key string) string

func (Req) GetQuery

func (r Req) GetQuery(k string) string

func (Req) GetUri

func (r Req) GetUri() string

type Resp

type Resp struct {
	Body       []byte
	StatusCode int
	Header     map[string]string
	Cookie     map[string]string
}

func (*Resp) SetCookie

func (r *Resp) SetCookie(key string, val string) error

func (*Resp) SetHeader

func (r *Resp) SetHeader(key string, val string) error

func (*Resp) SetRawBody

func (r *Resp) SetRawBody(body []byte) error

func (*Resp) SetStatusCode

func (r *Resp) SetStatusCode(code int) error

Jump to

Keyboard shortcuts

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