tests

package module
v0.0.0-...-b87209e Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package tests contains tests for go-orb/plugins/client/*.

Index

Constants

This section is empty.

Variables

View Source
var (
	ServiceName     = types.ServiceName("org.orb.svc.service")
	DefaultRequests = []TestRequest{
		{
			Name:     "32byte",
			Endpoint: "echo.Streams/Call",
			Request: &proto.CallRequest{
				Name: "32byte",
			},
			Response: &proto.CallResponse{
				Msg: "",
			},
			URL: "t",
		},

		{
			Name:     "default codec with URL",
			Endpoint: "echo.Streams/Call",
			Request: &proto.CallRequest{
				Name: "Alex",
			},
			Response: &proto.CallResponse{
				Msg: "Hello Alex",
			},
			URL: "t",
		},
		{
			Name:     "default codec",
			Endpoint: "echo.Streams/Call",
			Request: &proto.CallRequest{
				Name: "Alex",
			},
			Response: &proto.CallResponse{
				Msg: "Hello Alex",
			},
		},
		{
			Name:        "proto",
			Endpoint:    "echo.Streams/Call",
			ContentType: "application/x-protobuf",
			Request: &proto.CallRequest{
				Name: "Alex",
			},
			Response: &proto.CallResponse{
				Msg: "Hello Alex",
			},
		},
		{
			Name:        "json",
			Endpoint:    "echo.Streams/Call",
			ContentType: "application/json",
			Request: &proto.CallRequest{
				Name: "Alex",
			},
			Response: &proto.CallResponse{
				Msg: "Hello Alex",
			},
		},
		{
			Name:     "error request",
			Endpoint: "echo.Streams/Call",
			Error:    true,
			Request: &proto.CallRequest{
				Name: "error",
			},
			Response: &proto.CallResponse{
				Msg: "Hello Alex",
			},
		},
	}
)

Functions

This section is empty.

Types

type PackageRunner

type PackageRunner struct {
	// contains filtered or unexported fields
}

PackageRunner builds and runs go packages.

func NewPackageRunner

func NewPackageRunner(logger log.Logger, packagePath string, binaryPath string, opts ...PackageRunnerOption) *PackageRunner

NewPackageRunner creates a new package runner.

func (*PackageRunner) Build

func (p *PackageRunner) Build() error

Build makes a binary from the package.

func (*PackageRunner) Kill

func (p *PackageRunner) Kill() error

Kill kills the started process.

func (*PackageRunner) Start

func (p *PackageRunner) Start() error

Start runs the binary build with Build().

type PackageRunnerOption

type PackageRunnerOption func(*PackageRunnerOptions)

PackageRunnerOption is a option, see below.

func WithArgs

func WithArgs(n ...string) PackageRunnerOption

WithArgs sets commandline args.

func WithNumProcesses

func WithNumProcesses(n int) PackageRunnerOption

WithNumProcesses set's the number of parallel processes to start.

func WithOverwrite

func WithOverwrite() PackageRunnerOption

WithOverwrite recompiles the binary.

func WithRunEnv

func WithRunEnv(n ...string) PackageRunnerOption

WithRunEnv sets environment variables in the form of KEY=VAR.

func WithStdErr

func WithStdErr(n io.Writer) PackageRunnerOption

WithStdErr sets where to write stderr.

func WithStdOut

func WithStdOut(n io.Writer) PackageRunnerOption

WithStdOut sets where to write stdout.

type PackageRunnerOptions

type PackageRunnerOptions struct {
	OverWrite    bool
	StdOut       io.Writer
	StdErr       io.Writer
	RunEnv       []string
	Args         []string
	NumProcesses int
}

PackageRunnerOptions contains the options.

type TestRequest

type TestRequest struct {
	Name     string
	Service  string
	Endpoint string
	// PreferredTransports overwrites the list of preferred transports.
	PreferredTransports []string
	// ContentType overwrites the client's content-type.
	ContentType string
	// URL when set bypasses the registry.
	URL string
	// Expect an error?
	Error bool

	Request  any
	Response any
}

TestRequest contains all informations to run a test request.

type TestSuite

type TestSuite struct {
	suite.Suite

	// The path of plugins/
	PluginsRoot string

	// Transports is the list of preferred transports for all requests
	Transports []string

	// Requests is the requests to make.
	Requests []TestRequest
	// contains filtered or unexported fields
}

TestSuite runs a bunch of tests.

func NewSuite

func NewSuite(pluginsRoot string, transports []string, requests ...TestRequest) *TestSuite

NewSuite creates a new test suite.

func (*TestSuite) SetupSuite

func (s *TestSuite) SetupSuite()

SetupSuite setups the test suite.

func (*TestSuite) TearDownSuite

func (s *TestSuite) TearDownSuite()

TearDownSuite runs after all tests.

func (*TestSuite) TestResolveServiceTransport

func (s *TestSuite) TestResolveServiceTransport()

TestResolveServiceTransport checks if the right transport has been selected.

func (*TestSuite) TestRunRequests

func (s *TestSuite) TestRunRequests()

TestRunRequests makes the configured requests.

Directories

Path Synopsis
cmd
tests_server
Package main contains a server for running tests on.
Package main contains a server for running tests on.
Package handler provdes a test handler.
Package handler provdes a test handler.
Package proto ...
Package proto ...

Jump to

Keyboard shortcuts

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