Documentation
¶
Index ¶
- Constants
- Variables
- type AMQPMocks
- type Action
- type ActionDispatcher
- type ActionPublishAMQP
- type ActionPublishKafka
- type ActionRedis
- type ActionReplyHTTP
- type ActionSendHTTP
- type ActionSleep
- type Context
- type Expect
- type ExpectAMQP
- type ExpectHTTP
- type ExpectKafka
- type HTTPMocks
- type KafkaMocks
- type KafkaPipelineFunc
- type Mock
- type MockRepo
- type MocksArray
- type OpenMock
- func (om *OpenMock) Load() error
- func (om *OpenMock) ParseEnv()
- func (om *OpenMock) RedisDo(commandName string, args ...interface{}) (reply interface{}, err error)
- func (om *OpenMock) RedisTemplatesStore() string
- func (om *OpenMock) SetRedis()
- func (om *OpenMock) SetupLogrus()
- func (om *OpenMock) SetupRepo()
- func (om *OpenMock) Start()
- func (om *OpenMock) Stop()
- func (om *OpenMock) ToArray() []*Mock
- func (om *OpenMock) ToYAML() []byte
- type RedisDoer
Constants ¶
const ( KindBehavior = "Behavior" KindAbstractBehavior = "AbstractBehavior" KindTemplate = "Template" )
Variables ¶
var DefaultPipelineFunc = func(c Context, in []byte) (out []byte, err error) { return in, nil }
DefaultPipelineFunc directly outputs the in bytes
Functions ¶
This section is empty.
Types ¶
type ActionDispatcher ¶
type ActionDispatcher struct { Order int `yaml:"order,omitempty"` ActionPublishAMQP ActionPublishAMQP `yaml:"publish_amqp,omitempty"` ActionPublishKafka ActionPublishKafka `yaml:"publish_kafka,omitempty"` ActionRedis ActionRedis `yaml:"redis,omitempty"` ActionReplyHTTP ActionReplyHTTP `yaml:"reply_http,omitempty"` ActionSendHTTP ActionSendHTTP `yaml:"send_http,omitempty"` ActionSleep ActionSleep `yaml:"sleep,omitempty"` }
Action represents actions
type ActionPublishAMQP ¶
type ActionPublishAMQP struct { Exchange string `yaml:"exchange,omitempty"` RoutingKey string `yaml:"routing_key,omitempty"` Payload string `yaml:"payload,omitempty"` PayloadFromFile string `yaml:"payload_from_file,omitempty"` }
ActionPublishAMQP represents publish AMQP action
func (ActionPublishAMQP) Perform ¶
func (a ActionPublishAMQP) Perform(ctx Context) error
type ActionPublishKafka ¶
type ActionPublishKafka struct { Topic string `yaml:"topic,omitempty"` Payload string `yaml:"payload,omitempty"` PayloadFromFile string `yaml:"payload_from_file,omitempty"` }
ActionPublishKafka represents publish kafka action
func (ActionPublishKafka) Perform ¶
func (a ActionPublishKafka) Perform(ctx Context) error
type ActionRedis ¶
type ActionRedis []string
ActionRedis represents a list of redis commands
func (ActionRedis) Perform ¶
func (a ActionRedis) Perform(ctx Context) error
type ActionReplyHTTP ¶
type ActionReplyHTTP struct { StatusCode int `yaml:"status_code,omitempty"` Headers map[string]string `yaml:"headers,omitempty"` Body string `yaml:"body,omitempty"` BodyFromFile string `yaml:"body_from_file,omitempty"` }
ActionReplyHTTP represents reply http action
func (ActionReplyHTTP) Perform ¶
func (a ActionReplyHTTP) Perform(ctx Context) (err error)
type ActionSendHTTP ¶
type ActionSendHTTP struct { URL string `yaml:"url,omitempty"` Method string `yaml:"method,omitempty"` Headers map[string]string `yaml:"headers,omitempty"` Body string `yaml:"body,omitempty"` BodyFromFile string `yaml:"body_from_file,omitempty"` }
ActionSendHTTP represents the send http action
func (ActionSendHTTP) Perform ¶
func (a ActionSendHTTP) Perform(ctx Context) error
type ActionSleep ¶
ActionSleep represents the sleep action
func (ActionSleep) Perform ¶
func (a ActionSleep) Perform(ctx Context) error
type Context ¶
type Context struct { HTTPContext echo.Context HTTPHeader http.Header HTTPBody string HTTPPath string HTTPQueryString string KafkaTopic string KafkaPayload string AMQPExchange string AMQPRoutingKey string AMQPQueue string AMQPPayload string Values map[string]interface{} // contains filtered or unexported fields }
Context represents the context of the mock expectation
func (Context) MatchCondition ¶
MatchCondition checks the condition given the context
type Expect ¶
type Expect struct { Condition string `yaml:"condition,omitempty"` HTTP ExpectHTTP `yaml:"http,omitempty"` Kafka ExpectKafka `yaml:"kafka,omitempty"` AMQP ExpectAMQP `yaml:"amqp,omitempty"` }
Expect represents what to expect from a mock
type ExpectAMQP ¶
type ExpectAMQP struct { Exchange string `yaml:"exchange,omitempty"` RoutingKey string `yaml:"routing_key,omitempty"` Queue string `yaml:"queue,omitempty"` }
ExpectAMQP represents amqp expectation
type ExpectHTTP ¶
type ExpectHTTP struct { Method string `yaml:"method,omitempty"` Path string `yaml:"path,omitempty"` }
ExpectHTTP represents http expectation
type ExpectKafka ¶
type ExpectKafka struct {
Topic string `yaml:"topic,omitempty"`
}
ExpectKafka represents kafka expectation
type KafkaPipelineFunc ¶
KafkaPipelineFunc defines pipeline functions For example, decode/encode messages
type Mock ¶
type Mock struct { // Common fields Kind string `yaml:"kind,omitempty"` Key string `yaml:"key,omitempty"` Extend string `yaml:"extend,omitempty"` // KindBehavior fields Expect Expect `yaml:"expect,omitempty"` Actions []ActionDispatcher `yaml:"actions,omitempty"` Values map[string]interface{} `yaml:"values,omitempty"` // KindTemplate fields Template string `yaml:"template,omitempty"` }
Mock represents a mock struct swagger:model
type MockRepo ¶
type MockRepo struct { HTTPMocks HTTPMocks KafkaMocks KafkaMocks AMQPMocks AMQPMocks Templates MocksArray Behaviors map[string]*Mock }
MockRepo stores a repository of Mocks
type MocksArray ¶
type MocksArray []*Mock
MocksArray represents an array of Mocks
func (MocksArray) DoActions ¶
func (ms MocksArray) DoActions(ctx Context) error
type OpenMock ¶
type OpenMock struct { // Env configuration LogLevel string `env:"OPENMOCK_LOG_LEVEL" envDefault:"info"` TemplatesDir string `env:"OPENMOCK_TEMPLATES_DIR" envDefault:"./templates"` TemplatesDirHotReload bool `env:"OPENMOCK_TEMPLATES_DIR_HOT_RELOAD" envDefault:"true"` HTTPEnabled bool `env:"OPENMOCK_HTTP_ENABLED" envDefault:"true"` HTTPPort int `env:"OPENMOCK_HTTP_PORT" envDefault:"9999"` HTTPHost string `env:"OPENMOCK_HTTP_HOST" envDefault:"0.0.0.0"` AdminHTTPEnabled bool `env:"OPENMOCK_ADMIN_HTTP_ENABLED" envDefault:"true"` AdminHTTPPort int `env:"OPENMOCK_ADMIN_HTTP_PORT" envDefault:"9998"` AdminHTTPHost string `env:"OPENMOCK_ADMIN_HTTP_HOST" envDefault:"0.0.0.0"` KafkaEnabled bool `env:"OPENMOCK_KAFKA_ENABLED" envDefault:"false"` KafkaClientID string `env:"OPENMOCK_KAFKA_CLIENT_ID" envDefault:"openmock"` KafkaSeedBrokers []string `env:"OPENMOCK_KAFKA_SEED_BROKERS" envDefault:"kafka:9092" envSeparator:","` AMQPEnabled bool `env:"OPENMOCK_AMQP_ENABLED" envDefault:"false"` AMQPURL string `env:"OPENMOCK_AMQP_URL" envDefault:"amqp://guest:guest@rabbitmq:5672"` RedisType string `env:"OPENMOCK_REDIS_TYPE" envDefault:"memory"` RedisURL string `env:"OPENMOCK_REDIS_URL" envDefault:"redis://redis:6379"` CorsEnabled bool `env:"OPENMOCK_CORS_ENABLED" envDefault:"false"` // Customized pipeline functions KafkaConsumePipelineFunc KafkaPipelineFunc KafkaPublishPipelineFunc KafkaPipelineFunc // contains filtered or unexported fields }
OpenMock holds all the configuration of running openmock
func (*OpenMock) ParseEnv ¶
func (om *OpenMock) ParseEnv()
ParseEnv loads env vars into the openmock struct
func (*OpenMock) RedisTemplatesStore ¶
func (*OpenMock) SetRedis ¶
func (om *OpenMock) SetRedis()
SetRedis sets the Redis store for OpenMock
func (*OpenMock) SetupLogrus ¶
func (om *OpenMock) SetupLogrus()
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
pkg
|
|
swagger_gen
|
|
restapi
Package restapi OpenMock OpenMock is a Go service that can mock services in integration tests, staging environment, or anywhere.
|
Package restapi OpenMock OpenMock is a Go service that can mock services in integration tests, staging environment, or anywhere. |