util

package
v0.1.4-0...-4d5b6ff Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Column2

func Column2(rows *sql.Rows, row int) [][]byte

func Column3

func Column3(rows *sql.Rows, row int) [][]byte

func DurationToString

func DurationToString(d time.Duration) string

func GetPath

func GetPath(url *url.URL) (result string)

func HandleGet

func HandleGet(rows *sql.Rows, err error, closure func(*sql.Rows, int) [][]byte) ([][][]byte, myerror.Code)

handleGet used for Database get row

func HttpContentEncodingDecode

func HttpContentEncodingDecode(header http.Header, body io.ReadCloser, len int64, typ string) (string, error)

func JsonResponse

func JsonResponse(rw http.ResponseWriter, reply interface{})

func JsonResponseWS

func JsonResponseWS(rw *websocket.Conn, reply interface{})

func SaveReport

func SaveReport(uId string, report Report) error

func WasmForfeit

func WasmForfeit(wasmFileName string)

func WasmReplace

func WasmReplace(targets []string, slave []byte) error

func WasmUnforfeit

func WasmUnforfeit(wasmFileName string)

Types

type CurlCommand

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

CurlCommand contains exec.Command compatible slice + helpers

func GetCurlCommand

func GetCurlCommand(req *http.Request, body []byte) (*CurlCommand, error)

GetCurlCommand returns a CurlCommand corresponding to an http.Request

func (*CurlCommand) String

func (c *CurlCommand) String() string

String returns a ready to copy/paste command

type DB_Op

type DB_Op struct {
}

func (*DB_Op) GetError

func (d *DB_Op) GetError() error

func (*DB_Op) SetError

func (d *DB_Op) SetError(err error)

type Expectation

type Expectation struct {
	Pass        bool   `json:"pass"`
	Description string `json:"description"`
}

type Hit

type Hit struct {
	Command   string `json:"command"`
	StartTime string `json:"start_time"`
	Time      time.Time
}

type Mock

type Mock struct {
	Command  string `json:"command"`
	Request  string `json:"request"`
	Response string `json:"response"`
	Pass     bool   `json:"pass"`
	Index    int64  `json:"index"`
	Duration string `json:"duration"`
	EndTime  string `json:"end_time"`
	Source   string `json:"source"`
	TraceId  string `json:"trace_id"`
	Time     time.Time
}

type Report

type Report struct {
	Tests              []UnitTest `json:"tests"`
	StartTime          time.Time
	StartTimeFormatted string `json:"start_time_formatted"`
	EndTimeFormatted   string `json:"end_time_formatted"`
	Date               string `json:"date"`
	Duration           string `json:"duration"`
	TestEndPoint       string `json:"test_end_point"`
	Passes             int32  `json:"passes"`
	Skips              int32  `json:"skips"`
	TotalTests         int32  `json:"total_tests"`
	BackgroundMock     []Mock `json:"background_mock"`
	Hits               []Hit  `json:"hits"`
	Postman            string `json:"postman"`
	PostmanItem        []postman.Item
}

func ReportGen

func ReportGen() Report

type ReportLen

type ReportLen map[string]int64

type SafeHitMap

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

func NewSafeHitMap

func NewSafeHitMap() SafeHitMap

func (*SafeHitMap) Clone

func (c *SafeHitMap) Clone() []Hit

func (*SafeHitMap) Range

func (c *SafeHitMap) Range(fn func(hit Hit) bool)

func (*SafeHitMap) Store

func (c *SafeHitMap) Store(hit Hit)

type SafeIndexDb

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

func NewSafeIndexDb

func NewSafeIndexDb() SafeIndexDb

func (*SafeIndexDb) Delete

func (c *SafeIndexDb) Delete(key string)

func (*SafeIndexDb) Get

func (c *SafeIndexDb) Get(key string) ([]byte, error)

func (*SafeIndexDb) Store

func (c *SafeIndexDb) Store(key string, b []byte)

type SafeInstance

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

func NewSafeInstance

func NewSafeInstance(i wapc.Instance) SafeInstance

func (*SafeInstance) Close

func (c *SafeInstance) Close()

func (*SafeInstance) Invoke

func (c *SafeInstance) Invoke(ctx context.Context, g string, b []byte) ([]byte, error)

type SafeInstanceMap

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

func NewSafeInstanceMap

func NewSafeInstanceMap() SafeInstanceMap

func (*SafeInstanceMap) Delete

func (c *SafeInstanceMap) Delete(key string)

func (*SafeInstanceMap) Get

func (c *SafeInstanceMap) Get(key string) (*SafeInstance, bool)

func (*SafeInstanceMap) GetAll

func (c *SafeInstanceMap) GetAll() map[string]*SafeInstance

func (*SafeInstanceMap) Set

func (c *SafeInstanceMap) Set(key string, instance *SafeInstance)

type SafeReportLen

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

func SafeReportLenNew

func SafeReportLenNew() SafeReportLen

func (*SafeReportLen) CreateReport

func (c *SafeReportLen) CreateReport(uid string)

func (*SafeReportLen) DeleteReport

func (c *SafeReportLen) DeleteReport(uid string)

func (*SafeReportLen) Get

func (c *SafeReportLen) Get(uid string) int64

func (*SafeReportLen) Increment

func (c *SafeReportLen) Increment(uid string)

type SafeReports

type SafeReports struct {
	Reports map[string]Report
	// contains filtered or unexported fields
}

func (*SafeReports) AppendEnd

func (c *SafeReports) AppendEnd(uid string, backgroundMock []Mock, hit []Hit)

func (*SafeReports) AppendExpectation

func (c *SafeReports) AppendExpectation(uid string, ex Expectation)

func (*SafeReports) AppendMock

func (c *SafeReports) AppendMock(uid string, mock Mock)

func (*SafeReports) AppendPostmanItem

func (c *SafeReports) AppendPostmanItem(uid string, s postman.Item)

func (*SafeReports) AppendRequest

func (c *SafeReports) AppendRequest(uid string, req string) int64

func (*SafeReports) AppendResponse

func (c *SafeReports) AppendResponse(uid string, res string)

func (*SafeReports) AppendStep

func (c *SafeReports) AppendStep(uid string, s Step)

func (*SafeReports) AppendToLastStep

func (c *SafeReports) AppendToLastStep(uid string, s Step)

func (*SafeReports) AppendUnitTest

func (c *SafeReports) AppendUnitTest(uid string, index int64)

func (*SafeReports) ClearUnitTest

func (c *SafeReports) ClearUnitTest(uid string)

func (*SafeReports) Len

func (c *SafeReports) Len(uid string) int

func (*SafeReports) ReportGen

func (c *SafeReports) ReportGen(uid string)

func (*SafeReports) Save

func (c *SafeReports) Save(uid string)

func (*SafeReports) SetExpectation

func (c *SafeReports) SetExpectation(uid string, ex Expectation, index int)

func (*SafeReports) SetMock

func (c *SafeReports) SetMock(uid string, mock Mock, index int)

func (*SafeReports) SetRequest

func (c *SafeReports) SetRequest(uid string, req string, index int64) bool

func (*SafeReports) SetResponse

func (c *SafeReports) SetResponse(uid string, res string, index int)

func (*SafeReports) SetStep

func (c *SafeReports) SetStep(uid string, s Step, index int)

type SafeStringMap

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

func NewSafeStringMap

func NewSafeStringMap() SafeStringMap

func (*SafeStringMap) Delete

func (c *SafeStringMap) Delete(key string)

func (*SafeStringMap) Get

func (c *SafeStringMap) Get(key string) (string, bool)

func (*SafeStringMap) Range

func (c *SafeStringMap) Range(fn func(key string, value string) bool)

func (*SafeStringMap) Store

func (c *SafeStringMap) Store(key string, value string)

type SafeWsConn

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

func NewSafeWsConn

func NewSafeWsConn(i *websocket.Conn) SafeWsConn

func (*SafeWsConn) Close

func (c *SafeWsConn) Close()

func (*SafeWsConn) HostCall

func (c *SafeWsConn) HostCall() bool

func (*SafeWsConn) Lock

func (c *SafeWsConn) Lock()

func (*SafeWsConn) ReadJSON

func (c *SafeWsConn) ReadJSON(v interface{}) error

func (*SafeWsConn) ReadMessage

func (c *SafeWsConn) ReadMessage() (int, []byte, error)

func (*SafeWsConn) SetHostCall

func (c *SafeWsConn) SetHostCall(v bool)

func (*SafeWsConn) UnLock

func (c *SafeWsConn) UnLock()

func (*SafeWsConn) WriteJSON

func (c *SafeWsConn) WriteJSON(v interface{}) error

func (*SafeWsConn) WriteMessage

func (c *SafeWsConn) WriteMessage(m int, b []byte) error

type SafeWsConnMap

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

func NewSafeWsConnMap

func NewSafeWsConnMap() SafeWsConnMap

func (*SafeWsConnMap) Delete

func (c *SafeWsConnMap) Delete(key string)

func (*SafeWsConnMap) Get

func (c *SafeWsConnMap) Get(key string) (*SafeWsConn, bool)

func (*SafeWsConnMap) GetAll

func (c *SafeWsConnMap) GetAll() map[string]*SafeWsConn

func (*SafeWsConnMap) Set

func (c *SafeWsConnMap) Set(key string, conn *SafeWsConn)

func (*SafeWsConnMap) SizeHint

func (c *SafeWsConnMap) SizeHint() int

type Step

type Step struct {
	Pass        bool   `json:"pass"`
	Description string `json:"description"`
}

type Trace

type Trace struct {
	Request  TraceRequest  `json:"request"`
	Response TraceResponse `json:"response"`
}

func ConvertToTrace

func ConvertToTrace(resp *http.Response, readable_req_body string, readable_res_body string) Trace

type TraceRequest

type TraceRequest struct {
	Host            string `json:"host"`
	Path            string `json:"path"`
	Method          string `json:"method"`
	Minor           string `json:"minor"`
	Body            string `json:"body"`
	ContentLength   int64  `json:"content_length"`
	ContentEncoding string `json:"content_encoding"`
}

type TraceResponse

type TraceResponse struct {
	Minor           string `json:"minor"`
	Body            string `json:"body"`
	ContentLength   int64  `json:"content_length"`
	Time            int64  `json:"time"`
	Status          string `json:"status"`
	ContentEncoding string `json:"content_encoding"`
	ContentType     string `json:"content_type"`
}

type UnitTest

type UnitTest struct {
	Index              int64         `json:"index"`
	Expectations       []Expectation `json:"expectations"`
	MockData           []Mock        `json:"MockData"`
	Request            string        `json:"request"`
	Response           string        `json:"response"`
	Steps              []Step        `json:"Step"`
	StartTime          time.Time
	StartTimeFormatted string `json:"start_time_formatted"`
	EndTimeFormatted   string `json:"end_time_formatted"`
	Duration           string `json:"duration"`
}

func UnitTestGen

func UnitTestGen(index int64) UnitTest

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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