testutil

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package testutil contains helper functions for writing tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProjID

func ProjID() string

ProjID returns the project ID to use in integration tests, or the empty string if none is configured.

func TokenSource

func TokenSource(ctx context.Context, scopes ...string) oauth2.TokenSource

TokenSource returns the OAuth2 token source to use in integration tests, or nil if none is configured. TokenSource will log.Fatal if the token source is specified but missing or invalid.

Types

type Server

type Server struct {
	Addr string

	Gsrv *grpc.Server
	// contains filtered or unexported fields
}

A Server is an in-process gRPC server, listening on a system-chosen port on the local loopback interface. Servers are for testing only and are not intended to be used in production code.

To create a server, make a new Server, register your handlers, then call Start:

srv, err := NewServer()
...
mypb.RegisterMyServiceServer(srv.Gsrv, &myHandler)
....
srv.Start()

Clients should connect to the server with no security:

conn, err := grpc.Dial(srv.Addr, grpc.WithInsecure())
...

func NewServer

func NewServer() (*Server, error)

NewServer creates a new Server. The Server will be listening for gRPC connections at the address named by the Addr field, without TLS.

func (*Server) Close

func (s *Server) Close()

Close shuts down the server.

func (*Server) Start

func (s *Server) Start()

Start causes the server to start accepting incoming connections. Call Start after registering handlers.

Jump to

Keyboard shortcuts

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