tests

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const TEST_ADMIN_OPERATOR_ID = "Obsidian_Unit_Test_Admin_Operator"

Variables

View Source
var TestOperatorSerialNumber string

Functions

func GetHandlerByPathAndMethod

func GetHandlerByPathAndMethod(t *testing.T, handlers []obsidian.Handler, path string, method obsidian.HttpMethod) obsidian.Handler

GetHandlerByPathAndMethod fetches the first obsidian.Handler that matches the given path and method from a list of handlers. If no such handler exists, it will fail.

func JSONMarshaler

func JSONMarshaler(v interface{}) encoding.BinaryMarshaler

func RunTest

func RunTest(t *testing.T, tst Testcase) (int, string, error)

func RunUnitTest

func RunUnitTest(t *testing.T, e *echo.Echo, test Test)

RunUnitTest runs a test case using the given Echo instance. This function does not start an obsidian server..

func SendHttpRequest

func SendHttpRequest(method, url, payload string) (int, string, error)

SendHttpRequest is a wrapper to util.SendHttpRequest with extra test Admin Certificate HTTP Header which is needed to pass access control midleware

func StartObsidian

func StartObsidian(t *testing.T) int

Types

type Test

type Test struct {
	Method  string
	URL     string
	Payload encoding.BinaryMarshaler
	Handler echo.HandlerFunc

	ParamNames  []string
	ParamValues []string

	ExpectedStatus int
	ExpectedResult encoding.BinaryMarshaler

	ExpectedError string
}

type Testcase

type Testcase struct {
	Name                      string
	Method                    string
	Url                       string
	Payload                   string
	Expected                  string
	Skip_payload_verification bool
	Expect_http_error_status  bool
}

Jump to

Keyboard shortcuts

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