gnmitestutil

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package gnmitestutil implements a fake GNMI server with the ability to stub responses and fake schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeGNMI

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

FakeGNMI is a running fake GNMI server.

func StartGNMI

func StartGNMI(port int) (*FakeGNMI, error)

StartGNMI launches a new fake GNMI server on the given port

func (*FakeGNMI) Dial

func (g *FakeGNMI) Dial(ctx context.Context, opts ...grpc.DialOption) (gpb.GNMIClient, error)

Dial dials the fake gNMI client and returns a gNMI client stub.

func (*FakeGNMI) GetRequests

func (g *FakeGNMI) GetRequests() []*gpb.GetRequest

GetRequests returns the set of GetRequests sent to the gNMI server.

They're ordered in reverse time of request.

func (*FakeGNMI) LastRequestContextValues

func (g *FakeGNMI) LastRequestContextValues() *ygnmi.RequestValues

LastRequestContextValues returns the request-scoped values from the last ygnmi request sent to the gNMI server.

func (*FakeGNMI) Requests

func (g *FakeGNMI) Requests() []*gpb.SubscribeRequest

Requests returns the set of SubscribeRequests sent to the gNMI server.

func (*FakeGNMI) Stub

func (g *FakeGNMI) Stub() *Stubber

Stub reset the stubbed responses to empty and returns a handle to add new ones.

type SetClient

type SetClient struct {
	gpb.GNMIClient
	// Responses are the gNMI Responses to return from calls to Set.
	Responses []*gpb.SetResponse
	// Requests received by the client are stored in the slice.
	Requests []*gpb.SetRequest
	// ResponseErrs are the errors to return from calls to Set.
	ResponseErrs []error
	// contains filtered or unexported fields
}

func (*SetClient) AddResponse

func (f *SetClient) AddResponse(resp *gpb.SetResponse, err error) *SetClient

func (*SetClient) Reset

func (f *SetClient) Reset()

func (*SetClient) Set

func (f *SetClient) Set(_ context.Context, req *gpb.SetRequest, opts ...grpc.CallOption) (*gpb.SetResponse, error)

type Stubber

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

Stubber is a handle to add stubbed responses.

func (*Stubber) GetResponse

func (s *Stubber) GetResponse(gr *gpb.GetResponse, err error) *Stubber

GetResponse appends the given GetResponse as a stub response.

func (*Stubber) Notification

func (s *Stubber) Notification(n *gpb.Notification) *Stubber

Notification appends the given notification as a stub response.

func (*Stubber) Sync

func (s *Stubber) Sync() *Stubber

Sync appends a sync stub response.

Jump to

Keyboard shortcuts

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