models

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 7 Imported by: 45

Documentation

Index

Constants

View Source
const (
	MethodGet     Method = "GET"
	MethodPut            = "PUT"
	MethodHead           = "HEAD"
	MethodPost           = "POST"
	MethodPatch          = "PATCH" // RFC 5789
	MethodDelete         = "DELETE"
	MethodOptions        = "OPTIONS"
	MethodTrace          = "TRACE"
)
View Source
const (
	HTTP           Kind     = "Http"
	GENERIC        Kind     = "Generic"
	SQL            Kind     = "SQL"
	GRPC_EXPORT    Kind     = "gRPC"
	BodyTypeUtf8   BodyType = "utf-8"
	BodyTypeBinary BodyType = "binary"
)

Variables

View Source
var FailingColorScheme = pp.ColorScheme{
	Bool:            pp.Cyan | pp.Bold,
	Integer:         pp.Blue | pp.Bold,
	Float:           pp.Magenta | pp.Bold,
	String:          pp.Red,
	StringQuotation: pp.Red | pp.Bold,
	EscapedChar:     pp.Magenta | pp.Bold,
	FieldName:       pp.Yellow,
	PointerAdress:   pp.Blue | pp.Bold,
	Nil:             pp.Cyan | pp.Bold,
	Time:            pp.Blue | pp.Bold,
	StructName:      pp.White,
	ObjectLength:    pp.Blue,
}
View Source
var PassingColorScheme = pp.ColorScheme{
	String:          pp.Green,
	StringQuotation: pp.Green | pp.Bold,
	FieldName:       pp.White,
	Integer:         pp.Blue | pp.Bold,
	StructName:      pp.NoColor,
	Bool:            pp.Cyan | pp.Bold,
	Float:           pp.Magenta | pp.Bold,
	EscapedChar:     pp.Magenta | pp.Bold,
	PointerAdress:   pp.Blue | pp.Bold,
	Nil:             pp.Cyan | pp.Bold,
	Time:            pp.Blue | pp.Bold,
	ObjectLength:    pp.Blue,
}

Functions

This section is empty.

Types

type App

type App struct {
	ID      string `json:"id" bson:"_id"`
	Created int64  `json:"created_at" bson:"created,omitempty"`
	Updated int64  `json:"updated" bson:"updated,omitempty"`
	CID     string `json:"cid" bson:"CID"`
}

type AppDB

type AppDB interface {
	GetByCompany(ctx context.Context, cid string) ([]*App, error)
	Exists(ctx context.Context, cid, id string) (bool, error)
	Put(ctx context.Context, a *App) error
}

type BodyResult added in v0.7.0

type BodyResult struct {
	Normal   bool     `json:"normal" bson:"normal" yaml:"normal"`
	Type     BodyType `json:"type" bson:"type" yaml:"type"`
	Expected string   `json:"expected" bson:"expected" yaml:"expected"`
	Actual   string   `json:"actual" bson:"actual" yaml:"actual"`
}

type BodySegment

type BodySegment struct {
	Normal    bool
	Missing   bool
	Type      SegmentType
	ValueType SegmentValueType
	Key       string
	Value     *BodySegment
	String    string
	Number    float64
	Bool      bool
	Array     []BodySegment
}

type BodyType added in v0.7.0

type BodyType string
const (
	BodyTypePlain BodyType = "PLAIN"
	BodyTypeJSON  BodyType = "JSON"
	BodyTypeError BodyType = "ERROR"
)

type BrowserMock added in v0.5.0

type BrowserMock struct {
	ID       string                     `json:"id" bson:"_id"`
	Created  int64                      `json:"created" bson:"created,omitempty"`
	Updated  int64                      `json:"updated" bson:"updated,omitempty"`
	AppID    string                     `json:"app_id" bson:"app_id,omitempty"`
	TestName string                     `json:"test_name" bson:"test_name,omitempty"`
	Deps     []map[string]FetchResponse `json:"deps" bson:"deps,omitempty"`
}

type BrowserMockDB added in v0.5.0

type BrowserMockDB interface {
	Put(context.Context, BrowserMock) error
	Get(ctx context.Context, app string, testName string) ([]BrowserMock, error)
	CountDocs(ctx context.Context, app string, testName string) (int64, error)
	UpdateArr(ctx context.Context, app string, testName string, doc BrowserMock) error
}

type DepMetaResult added in v0.7.0

type DepMetaResult struct {
	Normal   bool   `json:"normal" bson:"normal" yaml:"normal"`
	Key      string `json:"key" bson:"key" yaml:"key"`
	Expected string `json:"expected" bson:"expected" yaml:"expected"`
	Actual   string `json:"actual" bson:"actual" yaml:"actual"`
}

type DepResult added in v0.7.0

type DepResult struct {
	Name string          `json:"name" bson:"name" yaml:"name"`
	Type DependencyType  `json:"type" bson:"type" yaml:"type"`
	Meta []DepMetaResult `json:"meta" bson:"meta" yaml:"meta"`
}

type Dependency

type Dependency struct {
	Name string            `json:"name" bson:"name,omitempty"`
	Type DependencyType    `json:"type" bson:"type,omitempty"`
	Meta map[string]string `json:"meta" bson:"meta,omitempty"`
	Data [][]byte          `json:"data" bson:"data,omitempty"`
}

type DependencyType

type DependencyType string
const (
	NoSqlDB    DependencyType = "NO_SQL_DB"
	SqlDB      DependencyType = "SQL_DB"
	GRPC       DependencyType = "GRPC"
	HttpClient DependencyType = "HTTP_CLIENT"
)

type FetchResponse added in v0.4.2

type FetchResponse struct {
	Status       int               `json:"status" bson:"status,omitempty"`
	Headers      map[string]string `json:"headers" bson:"headers,omitempty"`
	Body         interface{}       `json:"body" bson:"body,omitempty"`
	ResponseType string            `json:"response_type" bson:"response_type"`
}

type FormData added in v0.7.9

type FormData struct {
	Key    string   `json:"key" bson:"key" yaml:"key"`
	Values []string `json:"values" bson:"values,omitempty" yaml:"values,omitempty"`
	Paths  []string `json:"paths" bson:"paths,omitempty" yaml:"paths,omitempty"`
}

type GenericSpec added in v0.5.2

type GenericSpec struct {
	Metadata map[string]string `json:"metadata" yaml:"metadata"`
	Objects  []Object          `json:"objects" yaml:"objects"`
}

type GrpcReq added in v0.7.20

type GrpcReq struct {
	Body   string `json:"body" yaml:"body" bson:"body"`
	Method string `json:"method" yaml:"method" bson:"method"`
}

type GrpcResp added in v0.7.20

type GrpcResp struct {
	Body string `json:"body" yaml:"body" bson:"body"`
	Err  string `json:"error" yaml:"error" bson:"error"`
}

type GrpcSpec added in v0.7.20

type GrpcSpec struct {
	Metadata   map[string]string   `json:"metadata" yaml:"metadata"`
	Request    GrpcReq             `json:"grpc_req" yaml:"grpc_req"`
	Response   GrpcResp            `json:"grpc_resp" yaml:"grpc_resp"`
	Objects    []Object            `json:"objects" yaml:"objects"`
	Mocks      []string            `json:"mocks" yaml:"mocks,omitempty"`
	Assertions map[string][]string `json:"assertions" yaml:"assertions,omitempty"`
	Created    int64               `json:"created" yaml:"created,omitempty"`
}
type Header struct {
	Key   string   `json:"key" bson:"key" yaml:"key"`
	Value []string `json:"value" bson:"value" yaml:"value"`
}

type HeaderResult added in v0.7.0

type HeaderResult struct {
	Normal   bool   `json:"normal" bson:"normal" yaml:"normal"`
	Expected Header `json:"expected" bson:"expected" yaml:"expected"`
	Actual   Header `json:"actual" bson:"actual" yaml:"actual"`
}

type HttpReq

type HttpReq struct {
	Method     Method            `json:"method" bson:"method,omitempty" yaml:"method"`
	ProtoMajor int               `json:"proto_major" bson:"proto_major,omitempty" yaml:"proto_major"` // e.g. 1
	ProtoMinor int               `json:"proto_minor" bson:"proto_minor,omitempty" yaml:"proto_minor"` // e.g. 0
	URL        string            `json:"url" bson:"url,omitempty" yaml:"url"`
	URLParams  map[string]string `json:"url_params" bson:"url_params,omitempty" yaml:"url_params,omitempty"`
	Header     http.Header       `json:"header" bson:"header,omitempty" yaml:"headers"`
	Body       string            `json:"body" bson:"body,omitempty" yaml:"body"`
	Binary     string            `json:"binary" bson:"binary,omitempty" yaml:"binary,omitempty"`
	Form       []FormData        `json:"form" bson:"form,omitempty" yaml:"form,omitempty"`
}

type HttpResp

type HttpResp struct {
	StatusCode    int         `json:"status_code" bson:"status_code,omitempty" yaml:"status_code"` // e.g. 200
	Header        http.Header `json:"header" bson:"header,omitempty" yaml:"headers"`
	Body          string      `json:"body" bson:"body,omitempty" yaml:"body"`
	StatusMessage string      `json:"status_message" yaml:"status_message"`
	ProtoMajor    int         `json:"proto_major" yaml:"proto_major"`
	ProtoMinor    int         `json:"proto_minor" yaml:"proto_minor"`
	Binary        string      `json:"binary" bson:"binary,omitempty" yaml:"binary,omitempty"`
}

type HttpSpec added in v0.5.2

type HttpSpec struct {
	Metadata   map[string]string   `json:"metadata" yaml:"metadata"`
	Request    MockHttpReq         `json:"req" yaml:"req"`
	Response   MockHttpResp        `json:"resp" yaml:"resp"`
	Objects    []Object            `json:"objects" yaml:"objects"`
	Mocks      []string            `json:"mocks" yaml:"mocks,omitempty"`
	Assertions map[string][]string `json:"assertions" yaml:"assertions,omitempty"`
	Created    int64               `json:"created" yaml:"created,omitempty"`
}

type IntResult added in v0.7.0

type IntResult struct {
	Normal   bool `json:"normal" bson:"normal" yaml:"normal"`
	Expected int  `json:"expected" bson:"expected" yaml:"expected"`
	Actual   int  `json:"actual" bson:"actual" yaml:"actual"`
}

type Kind added in v0.5.2

type Kind string

type Method

type Method string

type Mock added in v0.4.2

type Mock struct {
	Version Version   `json:"version" yaml:"version"`
	Kind    Kind      `json:"kind" yaml:"kind"`
	Name    string    `json:"name" yaml:"name"`
	Spec    yaml.Node `json:"spec" yaml:"spec"`
}

type MockFS added in v0.7.0

type MockFS interface {
	ReadAll(ctx context.Context, testCasePath, mockPath, tcsType string) ([]TestCase, error)
	Read(ctx context.Context, path, name string, libMode bool) ([]Mock, error)
	Write(ctx context.Context, path string, doc Mock) error
	WriteAll(ctx context.Context, path, fileName string, docs []Mock) error
	Exists(ctx context.Context, path string) bool
}

type MockHttpReq added in v0.5.5

type MockHttpReq struct {
	Method     Method            `json:"method" yaml:"method"`
	ProtoMajor int               `json:"proto_major" yaml:"proto_major"` // e.g. 1
	ProtoMinor int               `json:"proto_minor" yaml:"proto_minor"` // e.g. 0
	URL        string            `json:"url" yaml:"url"`
	URLParams  map[string]string `json:"url_params" yaml:"url_params,omitempty"`
	Header     map[string]string `json:"header" yaml:"header"`
	Body       string            `json:"body" yaml:"body"`
	BodyType   string            `json:"body_type" yaml:"body_type"`
	Binary     string            `json:"binary" yaml:"binary,omitempty"`
	Form       []FormData        `json:"form" yaml:"form,omitempty"`
}

type MockHttpResp added in v0.5.5

type MockHttpResp struct {
	StatusCode    int               `json:"status_code" yaml:"status_code"` // e.g. 200
	Header        map[string]string `json:"header" yaml:"header"`
	Body          string            `json:"body" yaml:"body"`
	BodyType      string            `json:"body_type" yaml:"body_type"`
	StatusMessage string            `json:"status_message" yaml:"status_message"`
	ProtoMajor    int               `json:"proto_major" yaml:"proto_major"`
	ProtoMinor    int               `json:"proto_minor" yaml:"proto_minor"`
	Binary        string            `json:"binary" yaml:"binary,omitempty"`
}

type Object added in v0.5.0

type Object struct {
	Type string `json:"type" yaml:"type"`
	Data string `json:"data" yaml:"data"`
}

type Result added in v0.7.0

type Result struct {
	StatusCode    IntResult      `json:"status_code" bson:"status_code" yaml:"status_code"`
	HeadersResult []HeaderResult `json:"headers_result" bson:"headers_result" yaml:"headers_result"`
	BodyResult    []BodyResult   `json:"body_result" bson:"body_result" yaml:"body_result"`
	DepResult     []DepResult    `json:"dep_result" bson:"dep_result" yaml:"dep_result"`
}

type SQlSpec added in v0.7.6

type SQlSpec struct {
	Metadata map[string]string `json:"metadata" yaml:"metadata"`
	Type     SqlOutputType     `json:"type" yaml:"type"` // eg - POST : save data (TABLE) or number of rows affected (INT)
	Table    Table             `json:"table" yaml:"table,omitempty"`
	Int      int               `json:"int" yaml:"int"`
	Err      []string          `json:"error" yaml:"error",omitempty`
}

type SegmentType

type SegmentType string
const (
	ROOT  SegmentType = "ROOT"
	KEY   SegmentType = "KEY"
	VALUE SegmentType = "VALUE"
)

type SegmentValueType

type SegmentValueType string
const (
	STRING SegmentValueType = "STRING"
	NUMBER SegmentValueType = "NUMBER"
	BOOL   SegmentValueType = "BOOL"
	NULL   SegmentValueType = "NULL"
	ARRAY  SegmentValueType = "ARRAY"
	OBJECT SegmentValueType = "OBJECT"
)

type SqlCol added in v0.7.6

type SqlCol struct {
	Name string `json:"name" yaml:"name"`
	Type string `json:"type" yaml:"type"`
	// optional fields
	Precision int `json:"precision" yaml:"precision"`
	Scale     int `json:"scale" yaml:"scale"`
}

type SqlOutputType added in v0.7.6

type SqlOutputType string
const (
	TableType SqlOutputType = "table"
	IntType   SqlOutputType = "int"
	ErrType   SqlOutputType = "error"
)

type Table added in v0.7.6

type Table struct {
	Cols []SqlCol `json:"cols" yaml:"cols"`
	Rows []string `json:"rows" yaml:"rows"`
}

type TeleEvent added in v0.4.0

type TeleEvent struct {
	InstallationID string                 `json:"installationId"`
	EventType      string                 `json:"eventType"`
	Meta           map[string]interface{} `json:"meta"`
	CreatedAt      int64                  `json:"createdAt"`
	TeleCheck      bool                   `json:"tele_check"`
	OS             string                 `json:"os"`
	KeployVersion  string                 `json:"keploy_version"`
}

type Test added in v0.7.9

type Test struct {
	ID         string       `json:"id" bson:"_id"`
	Status     TestStatus   `json:"status" bson:"status"`
	Started    int64        `json:"started" bson:"started"`
	Completed  int64        `json:"completed" bson:"completed"`
	RunID      string       `json:"run_id" bson:"run_id"`
	TestCaseID string       `json:"testCaseID" bson:"test_case_id"`
	URI        string       `json:"uri" bson:"uri"`
	Req        HttpReq      `json:"req" bson:"req"`
	Dep        []Dependency `json:"dep" bson:"dep"`
	Resp       HttpResp     `json:"http_resp" bson:"http_resp,omitempty"`
	Noise      []string     `json:"noise" bson:"noise"`
	Result     Result       `json:"result" bson:"result"`
	// GrpcMethod string       `json:"grpc_method" bson:"grpc_method"`
	GrpcReq  GrpcReq  `json:"grpc_req" bson:"grpc_req"`
	GrpcResp GrpcResp `json:"grpc_resp" bson:"grpc_resp,omitempty"`
}

type TestCase

type TestCase struct {
	ID       string `json:"id" bson:"_id"`
	Created  int64  `json:"created" bson:"created,omitempty"`
	Updated  int64  `json:"updated" bson:"updated,omitempty"`
	Captured int64  `json:"captured" bson:"captured,omitempty"`
	CID      string `json:"cid" bson:"cid,omitempty"`
	AppID    string `json:"app_id" bson:"app_id,omitempty"`
	URI      string `json:"uri" bson:"uri,omitempty"`
	// GrpcMethod string              `json:"grpc_method" bson:"grpc_method,omitempty"`
	HttpReq  HttpReq             `json:"http_req" bson:"http_req,omitempty"`
	HttpResp HttpResp            `json:"http_resp" bson:"http_resp,omitempty"`
	GrpcReq  GrpcReq             `json:"grpc_req" bson:"grpc_req,omitempty"`
	GrpcResp GrpcResp            `json:"grpc_resp" bson:"grpc_resp,omitempty"`
	Deps     []Dependency        `json:"deps" bson:"deps,omitempty"`
	AllKeys  map[string][]string `json:"all_keys" bson:"all_keys,omitempty"`
	Anchors  map[string][]string `json:"anchors" bson:"anchors,omitempty"`
	Noise    []string            `json:"noise" bson:"noise,omitempty"`
	Mocks    []*proto.Mock       `json:"mocks"`
	Type     string              `json:"type" bson:"type,omitempty"`
}

type TestCaseDB

type TestCaseDB interface {
	Upsert(context.Context, TestCase) error
	UpdateTC(context.Context, TestCase) error
	Get(ctx context.Context, cid, id string) (TestCase, error)
	Delete(ctx context.Context, id string) error
	GetAll(ctx context.Context, cid, app, tcsType string, anchors bool, offset int, limit int) ([]TestCase, error)
	GetKeys(ctx context.Context, cid, app, uri, tcsType string) ([]TestCase, error)
	//Exists(context.Context, TestCase) (bool, error)
	DeleteByAnchor(ctx context.Context, cid, app, uri, tcsType string, filterKeys map[string][]string) error
	GetApps(ctx context.Context, cid string) ([]string, error)
}

type TestCaseReq added in v0.8.3

type TestCaseReq struct {
	Captured     int64             `json:"captured" bson:"captured"`
	AppID        string            `json:"app_id" bson:"app_id"`
	URI          string            `json:"uri" bson:"uri"`
	HttpReq      HttpReq           `json:"http_req" bson:"http_req"`
	HttpResp     HttpResp          `json:"http_resp" bson:"http_resp"`
	GrpcReq      GrpcReq           `json:"grpc_req" bson:"grpc_req"`
	GrpcResp     GrpcResp          `json:"grpc_resp" bson:"grpc_resp"`
	Deps         []Dependency      `json:"deps" bson:"deps"`
	TestCasePath string            `json:"test_case_path" bson:"test_case_path"`
	MockPath     string            `json:"mock_path" bson:"mock_path"`
	Mocks        []*proto.Mock     `json:"mocks" bson:"mocks"`
	Type         Kind              `json:"type" bson:"type"`
	Remove       []string          `json:"remove" bson:"remove"`
	Replace      map[string]string `json:"replace" bson:"replace"`
}

TestCaseReq is a struct for Http API request JSON body

func (*TestCaseReq) Bind added in v0.8.3

func (req *TestCaseReq) Bind(r *http.Request) error

type TestReport added in v0.7.0

type TestReport struct {
	Version Version      `json:"version" yaml:"version"`
	Name    string       `json:"name" yaml:"name"`
	Status  string       `json:"status" yaml:"status"`
	Success int          `json:"success" yaml:"success"`
	Failure int          `json:"failure" yaml:"failure"`
	Total   int          `json:"total" yaml:"total"`
	Tests   []TestResult `json:"tests" yaml:"tests,omitempty"`
}

type TestReq added in v0.8.3

type TestReq struct {
	ID           string   `json:"id" bson:"_id"`
	AppID        string   `json:"app_id" bson:"app_id"`
	RunID        string   `json:"run_id" bson:"run_id"`
	Resp         HttpResp `json:"resp" bson:"resp"`
	GrpcResp     GrpcResp `json:"grpc_resp" bson:"grpc_resp"`
	TestCasePath string   `json:"test_case_path" bson:"test_case_path"`
	MockPath     string   `json:"mock_path" bson:"mock_path"`
	Type         Kind     `json:"type" bson:"type"`
}

TestReq is a struct for Http API request JSON body

func (*TestReq) Bind added in v0.8.3

func (req *TestReq) Bind(r *http.Request) error

type TestResult added in v0.7.0

type TestResult struct {
	Kind         Kind         `json:"kind" yaml:"kind"`
	Name         string       `json:"name" yaml:"name"`
	Status       TestStatus   `json:"status" yaml:"status"`
	Started      int64        `json:"started" yaml:"started"`
	Completed    int64        `json:"completed" yaml:"completed"`
	TestCasePath string       `json:"testCasePath" yaml:"test_case_path"`
	MockPath     string       `json:"mockPath" yaml:"mock_path"`
	TestCaseID   string       `json:"testCaseID" yaml:"test_case_id"`
	Req          MockHttpReq  `json:"req" yaml:"req,omitempty"`
	Mocks        []string     `json:"mocks" yaml:"mocks"`
	Res          MockHttpResp `json:"resp" yaml:"resp,omitempty"`
	Noise        []string     `json:"noise" yaml:"noise,omitempty"`
	Result       Result       `json:"result" yaml:"result"`
	GrpcReq      GrpcReq      `json:"grpc_req" yaml:"grpc_req,omitempty"`
	GrpcResp     GrpcResp     `json:"grpc_resp" yaml:"grpc_resp,omitempty"`
}

type TestRun added in v0.7.9

type TestRun struct {
	ID      string        `json:"id" bson:"_id"`
	Created int64         `json:"created" bson:"created,omitempty"`
	Updated int64         `json:"updated" bson:"updated,omitempty"`
	Status  TestRunStatus `json:"status" bson:"status"`
	CID     string        `json:"cid" bson:"cid,omitempty"`
	App     string        `json:"app" bson:"app,omitempty"`
	User    string        `json:"user" bson:"user,omitempty"`
	Success int           `json:"success" bson:"success,omitempty"`
	Failure int           `json:"failure" bson:"failure,omitempty"`
	Total   int           `json:"total" bson:"total,omitempty"`
	Tests   []Test        `json:"tests" bson:"-"`
}

type TestRunStatus added in v0.7.0

type TestRunStatus string
const (
	TestRunStatusRunning TestRunStatus = "RUNNING"
	TestRunStatusFailed  TestRunStatus = "FAILED"
	TestRunStatusPassed  TestRunStatus = "PASSED"
)

type TestStatus added in v0.7.0

type TestStatus string
const (
	TestStatusPending TestStatus = "PENDING"
	TestStatusRunning TestStatus = "RUNNING"
	TestStatusFailed  TestStatus = "FAILED"
	TestStatusPassed  TestStatus = "PASSED"
)

type Version added in v0.5.2

type Version string
const (
	V1Beta1 Version = Version("api.keploy.io/v1beta1")
	V1Beta2 Version = Version("api.keploy.io/v1beta2")
)

Jump to

Keyboard shortcuts

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