tests

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 14 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 is the name of the testing service.
	ServiceName = "service"

	// DefaultRequests is the list of default requests.
	DefaultRequests = []TestRequest{
		{
			Name:     "32byte",
			Service:  ServiceName,
			Endpoint: echo.EndpointStreamsCall,
			Request: &echo.CallRequest{
				Name: "32byte",
			},
			Response: &echo.CallResponse{
				Msg: "",
			},
		},
		{
			Name:        "raw-json",
			Service:     ServiceName,
			Endpoint:    echo.EndpointStreamsCall,
			ContentType: "application/json",
			Request:     `{"name": "Alex"}`,
			Response: map[string]any{
				"msg": "Hello Alex",
			},
		},
		{
			Name:     "default codec with URL",
			Service:  ServiceName,
			Endpoint: echo.EndpointStreamsCall,
			Request: &echo.CallRequest{
				Name: "Alex",
			},
			Response: &echo.CallResponse{
				Msg: "Hello Alex",
			},
		},
		{
			Name:     "default codec",
			Service:  ServiceName,
			Endpoint: echo.EndpointStreamsCall,
			Request: &echo.CallRequest{
				Name: "Alex",
			},
			Response: &echo.CallResponse{
				Msg: "Hello Alex",
			},
		},
		{
			Name:        "proto",
			Service:     ServiceName,
			Endpoint:    echo.EndpointStreamsCall,
			ContentType: "application/x-protobuf",
			Request: &echo.CallRequest{
				Name: "Alex",
			},
			Response: &echo.CallResponse{
				Msg: "Hello Alex",
			},
		},
		{
			Name:        "json",
			Service:     ServiceName,
			Endpoint:    echo.EndpointStreamsCall,
			ContentType: "application/json",
			Request: map[string]any{
				"name": "Alex",
			},
			Response: map[string]any{
				"msg": "Hello Alex",
			},
		},
		{
			Name:     "error request",
			Service:  ServiceName,
			Endpoint: echo.EndpointStreamsCall,
			Error:    true,
			Request: &echo.CallRequest{
				Name: "error",
			},
			Response: &echo.CallResponse{
				Msg: "Hello Alex",
			},
		},
	}
)

Functions

This section is empty.

Types

type SetupData added in v0.3.0

type SetupData struct {
	Logger      log.Logger
	Registry    registry.Type
	Entrypoints []server.Entrypoint
	Ctx         context.Context
	Stop        context.CancelFunc
}

SetupData contains the setup data for a test.

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
	// 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

	// 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(setupServer func(service string) (*SetupData, error),
	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) TestAuthorizedFileUpload added in v0.3.0

func (s *TestSuite) TestAuthorizedFileUpload()

TestAuthorizedFileUpload tests the authorized client streaming functionality for file uploads.

func (*TestSuite) TestFailingAuthorization

func (s *TestSuite) TestFailingAuthorization()

TestFailingAuthorization tests an authorization call that must fail.

func (*TestSuite) TestFileUpload added in v0.3.0

func (s *TestSuite) TestFileUpload()

TestFileUpload tests the client streaming functionality for file uploads.

func (*TestSuite) TestMetadata

func (s *TestSuite) TestMetadata()

TestMetadata checks if metadata gets transported over the wire.

func (*TestSuite) TestRunRequests

func (s *TestSuite) TestRunRequests()

TestRunRequests makes the configured requests.

Directories

Path Synopsis
handler
echo
Package echo provides the echo test handler.
Package echo provides the echo test handler.
file
Package file implements a file service.
Package file implements a file service.
Package proto ...
Package proto ...

Jump to

Keyboard shortcuts

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