mock

package
v2.1.1-0...-182a82a Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefinePropertyPaths

func DefinePropertyPaths(collection *Collection)

DefinePropertyPaths defines all property paths inside the given collection

func SchemaResolver

func SchemaResolver(path string) providers.SchemaResolver

SchemaResolver returns a new schema resolver for the given mock collection

func ServiceManifest

func ServiceManifest(collection *Collection) specs.ServiceList

ServiceManifest formats the given mock collection to a specs service(s) manifest

func ServicesResolver

func ServicesResolver(path string) providers.ServicesResolver

ServicesResolver returns a new service(s) resolver for the given mock collection

func SpecsMethod

func SpecsMethod(method *Method) *specs.Method

SpecsMethod formats the given mock method to a specs method

func SpecsService

func SpecsService(service *Service) *specs.Service

SpecsService formats the given mock service to a specs service

Types

type Collection

type Collection struct {
	Exception  Exception                  `yaml:"exception"`
	Services   map[string]*Service        `yaml:"services"`
	Properties map[string]*specs.Property `yaml:"properties"`
}

Collection represents a mock YAML file

func CollectionResolver

func CollectionResolver(path string) (*Collection, error)

CollectionResolver returns the full mock collection

func NewCollection

func NewCollection(descriptor Collection) *Collection

NewCollection constructs a new schema collection from the given descriptors

func UnmarshalFile

func UnmarshalFile(reader io.Reader) (*Collection, error)

UnmarshalFile attempts to parse the given Mock YAML file to intermediate resources.

func (*Collection) GetService

func (collection *Collection) GetService(name string) *Service

GetService attempts to find the given service

func (*Collection) GetServices

func (collection *Collection) GetServices() []*Service

GetServices returns all available services inside the given collection

type Exception

type Exception struct {
	File    string `yaml:"file"`
	Line    int    `yaml:"line"`
	Message string `yaml:"message"`
}

Exception represents a exception thrown during runtime

type Method

type Method struct {
	Name    string
	Comment string        `yaml:"comment"`
	Input   string        `yaml:"input"`
	Output  string        `yaml:"output"`
	Options specs.Options `yaml:"options"`
}

Method represents a mock YAML service method

func NewMethod

func NewMethod(name string, method *Method) *Method

NewMethod constructs a new method with the given descriptor

type Service

type Service struct {
	Name      string
	Package   string             `yaml:"package"`
	Comment   string             `yaml:"comment"`
	Host      string             `yaml:"host"`
	Transport string             `yaml:"transport"`
	Codec     string             `yaml:"codec"`
	Methods   map[string]*Method `yaml:"methods"`
	Options   specs.Options      `yaml:"options"`
}

Service represents a mocking service

func NewService

func NewService(name string, service *Service) *Service

NewService constructs a new service with the given descriptor

func (*Service) GetMethod

func (service *Service) GetMethod(name string) *Method

GetMethod attempts to return the given service method

func (*Service) GetMethods

func (service *Service) GetMethods() []*Method

GetMethods attempts to return the given service methods

Jump to

Keyboard shortcuts

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