keploy

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: Apache-2.0 Imports: 23 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertTests added in v0.2.0

func AssertTests(t *testing.T)

func CaptureTestcase added in v0.2.0

func CaptureTestcase(k *Keploy, r *http.Request, reqBody []byte, resp models.HttpResp, params map[string]string)

func Decode

func Decode(bin []byte, obj interface{}) (interface{}, error)

Decode returns the decoded data by using gob decoder on bin parameter.

func Encode

func Encode(obj interface{}, arr [][]byte, pos int) error

Encode takes obj parameter and encodes its contents into arr parameter. If obj have no exported field then, it returns an error.

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 "test" mode, it returns (true, decoded outputs of stored binaries in keploy context). Else in "capture" mode, it encodes the outputs of external dependencies and stores in keploy context. Returns (false, nil).

func SetMode added in v0.2.0

func SetMode(m Mode) error

SetMode sets the keploy SDK mode error is returned if the mode is invalid

func SetTestMode added in v0.2.0

func SetTestMode()

SetTestMode sets the keploy SDK mode to MODE_TEST

Types

type AppConfig added in v0.2.0

type AppConfig struct {
	Name    string        `validate:"required"`
	Host    string        `default:"0.0.0.0"`
	Port    string        `validate:"required"`
	Delay   time.Duration `default:"5s"`
	Timeout time.Duration `default:"60s"`
}

type BodyDumpResponseWriter added in v0.2.0

type BodyDumpResponseWriter struct {
	io.Writer
	http.ResponseWriter
	Status int
}

func (*BodyDumpResponseWriter) Flush added in v0.2.0

func (w *BodyDumpResponseWriter) Flush()

func (*BodyDumpResponseWriter) Hijack added in v0.2.0

func (*BodyDumpResponseWriter) Write added in v0.2.0

func (w *BodyDumpResponseWriter) Write(b []byte) (int, error)

func (*BodyDumpResponseWriter) WriteHeader added in v0.2.0

func (w *BodyDumpResponseWriter) WriteHeader(code int)

type Config added in v0.2.0

type Config struct {
	App    AppConfig
	Server ServerConfig
}

type Context

type Context struct {
	Mode   Mode
	TestID string
	Deps   []models.Dependency
}

func GetState

func GetState(ctx context.Context) (*Context, error)

GetState returns value of "KeployContext" key-value pair which is stored in the request context.

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.

func (*KError) Error

func (e *KError) Error() string

Error method returns error string stored in Err field of KError.

func (*KError) GobDecode

func (e *KError) GobDecode(b []byte) error

GobDecode decodes the b([]byte) into error struct.

func (*KError) GobEncode

func (e *KError) GobEncode() ([]byte, error)

GobEncode encodes the Err and returns the binary data.

type KctxType

type KctxType string
const KCTX KctxType = "KeployContext"

type Keploy added in v0.2.0

type Keploy struct {
	Log *zap.Logger
	// contains filtered or unexported fields
}

func New added in v0.2.0

func New(cfg Config) *Keploy

func (*Keploy) Capture added in v0.2.0

func (k *Keploy) Capture(req regression.TestCaseReq)

Capture will capture request, response and output of external dependencies by making Call to keploy server.

func (*Keploy) Get added in v0.2.0

func (k *Keploy) Get(id string) *models.TestCase

func (*Keploy) GetDependencies added in v0.2.1

func (k *Keploy) GetDependencies(id string) []models.Dependency

func (*Keploy) GetResp added in v0.2.1

func (k *Keploy) GetResp(id string) models.HttpResp

func (*Keploy) PutResp added in v0.2.1

func (k *Keploy) PutResp(id string, resp models.HttpResp)

func (*Keploy) Test added in v0.2.0

func (k *Keploy) Test()

Test fetches the testcases from the keploy server and current response of API. Then, both of the responses are sent back to keploy's server for comparision.

type Mode added in v0.2.0

type Mode string

Mode represents the mode at which the SDK is operating MODE_RECORD is for recording API calls to generate testcases MODE_TEST is for testing the application on previous recorded testcases MODE_OFF disables keploy SDK automatically from the application

const (
	MODE_RECORD Mode = "record"
	MODE_TEST   Mode = "test"
	MODE_OFF    Mode = "off"
)

func GetMode

func GetMode() Mode

GetMode returns the mode of the keploy SDK

func GetModeFromContext added in v0.2.0

func GetModeFromContext(ctx context.Context) Mode

GetModeFromContext returns the mode on which SDK is configured by accessing environment variable.

func (Mode) Valid added in v0.2.0

func (m Mode) Valid() bool

Valid checks if the provided mode is valid

type ServerConfig added in v0.2.0

type ServerConfig struct {
	URL        string `default:"https://api.keploy.io"`
	LicenseKey string
}

Jump to

Keyboard shortcuts

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