testing

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 6 Imported by: 9

Documentation

Overview

Package testing provide the test case functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clean

type Clean struct {
	CleanPrepare bool `yaml:"cleanPrepare"`
}

Clean represents the clean work after testing

type Prepare

type Prepare struct {
	Kubernetes []string `yaml:"kubernetes"`
}

Prepare does the prepare work

type Request

type Request struct {
	API          string            `yaml:"api" json:"api"`
	Method       string            `yaml:"method,omitempty" json:"method,omitempty" jsonschema:"enum=GET,enum=POST,enum=PUT,enum=DELETE"`
	Query        map[string]string `yaml:"query" json:"query,omitempty"`
	Header       map[string]string `yaml:"header" json:"header,omitempty"`
	Form         map[string]string `yaml:"form" json:"form,omitempty"`
	Body         string            `yaml:"body" json:"body,omitempty"`
	BodyFromFile string            `yaml:"bodyFromFile" json:"bodyFromFile,omitempty"`
}

Request represents a HTTP request

func (*Request) Render added in v0.0.2

func (r *Request) Render(ctx interface{}) (err error)

Render injects the template based context

type Response

type Response struct {
	StatusCode       int                    `yaml:"statusCode" json:"bodyFromFile,omitempty"`
	Body             string                 `yaml:"body" json:"body,omitempty"`
	Header           map[string]string      `yaml:"header" json:"header,omitempty"`
	BodyFieldsExpect map[string]interface{} `yaml:"bodyFieldsExpect" json:"bodyFieldsExpect,omitempty"`
	Verify           []string               `yaml:"verify" json:"verify,omitempty"`
}

Response is the expected response

func (*Response) Render added in v0.0.3

func (r *Response) Render(ctx interface{}) (err error)

Render renders the response

type TestCase

type TestCase struct {
	Name    string `yaml:"name" json:"name"`
	Group   string
	Prepare Prepare  `yaml:"prepare" json:"-"`
	Request Request  `yaml:"request" json:"request"`
	Expect  Response `yaml:"expect" json:"expect"`
	Clean   Clean    `yaml:"clean" json:"-"`
}

TestCase represents a test case

func ParseTestCaseFromData added in v0.0.5

func ParseTestCaseFromData(data []byte) (testCase *TestCase, err error)

ParseTestCaseFromData parses the data to a test case

type TestSuite added in v0.0.2

type TestSuite struct {
	Name  string     `yaml:"name" json:"name"`
	API   string     `yaml:"api,omitempty" json:"api,omitempty"`
	Items []TestCase `yaml:"items" json:"items"`
}

TestSuite represents a set of test cases

func Parse

func Parse(configFile string) (testSuite *TestSuite, err error)

Parse parses a file and returns the test suite

func ParseFromData added in v0.0.5

func ParseFromData(data []byte) (testSuite *TestSuite, err error)

ParseFromData parses data and returns the test suite

Jump to

Keyboard shortcuts

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