Documentation
¶
Index ¶
- Constants
- Variables
- func AssertTests(t *testing.T)
- func CaptureGrpcTC(k *Keploy, grpcCtx context.Context, req models.GrpcReq, resp models.GrpcResp)
- func CaptureHttpTC(k *Keploy, r *http.Request, reqBody []byte, resp models.HttpResp, ...)
- func Decode(bin []byte, obj interface{}) (interface{}, error)
- func Encode(obj interface{}, arr [][]byte, pos int) error
- func GetMode() keploy.Mode
- func GrpCurl(grpcReq string, id string, port string, method string) error
- func Middleware(k *Keploy, router Router) error
- func NewCustomHandler(c *grpcurl.DefaultEventHandler) grpcurl.InvocationEventHandler
- func ProcessDep(ctx context.Context, log *zap.Logger, meta map[string]string, ...) (bool, []interface{})
- func SetTestMode()
- type AppConfig
- type BodyDumpResponseWriter
- type Config
- type CustomHandler
- type Filter
- type GrpcResp
- type HttpResp
- type KError
- type Keploy
- func (k *Keploy) Capture(req models.TestCaseReq)
- func (k *Keploy) Get(id string) *models.TestCase
- func (k *Keploy) GetClock(id string) int64
- func (k *Keploy) GetDependencies(id string) []models.Dependency
- func (k *Keploy) GetMocks(id string) []*proto.Mock
- func (k *Keploy) GetResp(id string) HttpResp
- func (k *Keploy) GetRespGrpc(id string) GrpcResp
- func (k *Keploy) PutResp(id string, resp HttpResp)
- func (k *Keploy) PutRespGrpc(id string, resp GrpcResp)
- func (k *Keploy) Test()
- type Router
- type ServerConfig
Constants ¶
Variables ¶
var (
RespChannels = map[string]chan bool{}
)
Functions ¶
func AssertTests ¶
func CaptureGrpcTC ¶
func CaptureHttpTC ¶
func Encode ¶
Encode takes obj parameter and encodes its contents into arr parameter. If obj have no exported field then, it returns an error.
func GrpCurl ¶
GrpCurl function acts as a grpc client for the simulate client. It takes grpcRequest json , testcase id, port and request method as its parameter
func Middleware ¶
func NewCustomHandler ¶
func NewCustomHandler(c *grpcurl.DefaultEventHandler) grpcurl.InvocationEventHandler
func ProcessDep ¶
func ProcessDep(ctx context.Context, log *zap.Logger, meta map[string]string, outputs ...interface{}) (bool, []interface{})
ProcessDep is a generic method to encode and decode the outputs of external dependecies. If request is on keploy.MODE_TEST mode, it returns (true, decoded outputs of stored binaries in keploy context). Else in keploy.MODE_RECORD mode, it encodes the outputs of external dependencies and stores in keploy context. Returns (false, nil).
Types ¶
type BodyDumpResponseWriter ¶
type BodyDumpResponseWriter struct { io.Writer http.ResponseWriter Status int }
func ProcessRequest ¶
func (*BodyDumpResponseWriter) Flush ¶
func (w *BodyDumpResponseWriter) Flush()
func (*BodyDumpResponseWriter) Hijack ¶
func (w *BodyDumpResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*BodyDumpResponseWriter) Write ¶
func (w *BodyDumpResponseWriter) Write(b []byte) (int, error)
func (*BodyDumpResponseWriter) WriteHeader ¶
func (w *BodyDumpResponseWriter) WriteHeader(code int)
type Config ¶
type Config struct { App AppConfig Server ServerConfig }
type CustomHandler ¶
type CustomHandler struct {
*grpcurl.DefaultEventHandler
}
func (*CustomHandler) OnReceiveResponse ¶
func (h *CustomHandler) OnReceiveResponse(protoiface.MessageV1)
type KError ¶
type KError struct {
Err error
}
KError stores the error for encoding and decoding as errorString has no exported fields due to gob wasn't able to encode the unexported fields.
type Keploy ¶
type Keploy struct { Ctx context.Context Log *zap.Logger // contains filtered or unexported fields }
func (*Keploy) Capture ¶
func (k *Keploy) Capture(req models.TestCaseReq)
Capture will capture request, response and output of external dependencies by making Call to keploy server.
func (*Keploy) GetDependencies ¶
func (k *Keploy) GetDependencies(id string) []models.Dependency
func (*Keploy) GetRespGrpc ¶
func (*Keploy) PutRespGrpc ¶
type Router ¶
type Router interface { // GetRequest provides access to the current http request object. // Example: echo.Context.Request() GetRequest() *http.Request // SetRequest sets the http request with given request object parameter. SetRequest(*http.Request) // GetResponseWriter returns current ResponseWriter of the http handler. GetResponseWriter() http.ResponseWriter // SetResponseWriter sets the ResponseWriter of http handler with given parameter. SetResponseWriter(http.ResponseWriter) // Context returns the underlying context of the http.Request. Context() context.Context // Next is used to call the next handler of the middleware chain. Next() error // GetURLParams returns the url parameter as key:value pair. GetURLParams() map[string]string }