Documentation ¶
Overview ¶
Package testutil implements a fake GNMI server with the ability to stub responses and fake schema.
Index ¶
- func GNMIPath(t testing.TB, s string) *gpb.Path
- func GetSchemaStruct() func() *ytypes.Schema
- type Device
- type EnumType
- type EnumType2
- type FakeGNMI
- type LeafContainerStruct
- func (*LeafContainerStruct) IsYANGGoStruct()
- func (*LeafContainerStruct) To_UnionLeafType(i interface{}) (UnionLeafType, error)
- func (*LeafContainerStruct) Validate(opts ...ygot.ValidationOption) error
- func (*LeafContainerStruct) ΛBelongingModule() string
- func (*LeafContainerStruct) ΛEnumTypeMap() map[string][]reflect.Type
- type Model
- func (*Model) IsYANGGoStruct()
- func (t *Model) NewSingleKey(Key int32) (*Model_SingleKey, error)
- func (t *Model) RenameSingleKey(oldK, newK int32) error
- func (*Model) Validate(opts ...ygot.ValidationOption) error
- func (*Model) ΛBelongingModule() string
- func (*Model) ΛEnumTypeMap() map[string][]reflect.Type
- type Model_SingleKey
- type SetClient
- type Stubber
- type SuperContainer
- type UnionLeafType
- type UnionLeafType_EnumType
- type UnionLeafType_EnumType2
- type UnionLeafType_String
- type UnionLeafType_Uint32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSchemaStruct ¶
Types ¶
type Device ¶
type Device struct {
SuperContainer *SuperContainer `path:"super-container" module:"yang-module"`
}
Device is the fake root.
func (*Device) IsYANGGoStruct ¶
func (*Device) IsYANGGoStruct()
func (*Device) ΛBelongingModule ¶
type EnumType ¶
type EnumType int64
EnumType is used as an enum type in various tests in the ytypes package.
func (EnumType) IsYANGGoEnum ¶
func (EnumType) IsYANGGoEnum()
type EnumType2 ¶
type EnumType2 int64
EnumType2 is used as an enum type in various tests in the ytypes package.
func (EnumType2) IsYANGGoEnum ¶
func (EnumType2) IsYANGGoEnum()
type FakeGNMI ¶
type FakeGNMI struct {
// contains filtered or unexported fields
}
FakeGNMI is a running fake GNMI server.
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 ¶ added in v0.2.0
func (g *FakeGNMI) GetRequests() []*gpb.GetRequest
GetRequests returns the set of GetRequests 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.
type LeafContainerStruct ¶
type LeafContainerStruct struct { Uint64Leaf *uint64 `path:"uint64-leaf" shadow-path:"state/uint64-leaf"` EnumLeaf EnumType `path:"enum-leaf"` UnionLeaf UnionLeafType `path:"union-leaf"` UnionLeaf2 EnumType `path:"union-leaf2"` UnionLeafSingleType []string `path:"union-stleaflist"` }
func (*LeafContainerStruct) IsYANGGoStruct ¶
func (*LeafContainerStruct) IsYANGGoStruct()
func (*LeafContainerStruct) To_UnionLeafType ¶
func (*LeafContainerStruct) To_UnionLeafType(i interface{}) (UnionLeafType, error)
func (*LeafContainerStruct) Validate ¶
func (*LeafContainerStruct) Validate(opts ...ygot.ValidationOption) error
func (*LeafContainerStruct) ΛBelongingModule ¶
func (*LeafContainerStruct) ΛBelongingModule() string
func (*LeafContainerStruct) ΛEnumTypeMap ¶
func (*LeafContainerStruct) ΛEnumTypeMap() map[string][]reflect.Type
type Model ¶
type Model struct {
SingleKey map[int32]*Model_SingleKey `path:"a/single-key"`
}
func (*Model) IsYANGGoStruct ¶
func (*Model) IsYANGGoStruct()
func (*Model) NewSingleKey ¶
func (t *Model) NewSingleKey(Key int32) (*Model_SingleKey, error)
NewSingleKey is a *generated* method for Model which may be used by an unmarshal function in ytype's reflect library, and is kept here in case.
func (*Model) RenameSingleKey ¶
RenameSingleKey is a *generated* method for Model which may be used by an unmarshal function in ytype's reflect library, and is kept here in case. RenameSingleKey renames an entry in the list SingleKey within the Model struct. The entry with key oldK is renamed to newK updating the key within the value.
func (*Model) ΛBelongingModule ¶
type Model_SingleKey ¶
type Model_SingleKey struct { Key *int32 `path:"config/key|key" shadow-path:"state/key"` Value *int64 `path:"config/value" shadow-path:"state/value"` }
func (*Model_SingleKey) IsYANGGoStruct ¶
func (*Model_SingleKey) IsYANGGoStruct()
func (*Model_SingleKey) Validate ¶
func (*Model_SingleKey) Validate(opts ...ygot.ValidationOption) error
func (*Model_SingleKey) ΛBelongingModule ¶
func (*Model_SingleKey) ΛBelongingModule() string
func (*Model_SingleKey) ΛEnumTypeMap ¶
func (*Model_SingleKey) ΛEnumTypeMap() map[string][]reflect.Type
func (*Model_SingleKey) ΛListKeyMap ¶
func (t *Model_SingleKey) ΛListKeyMap() (map[string]interface{}, error)
ΛListKeyMap returns the keys of the Model_SingleKey struct, which is a YANG list entry.
type SetClient ¶ added in v0.6.0
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 ¶ added in v0.6.0
func (f *SetClient) AddResponse(resp *gpb.SetResponse, err error) *SetClient
func (*SetClient) Set ¶ added in v0.6.0
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 ¶ added in v0.2.1
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.
type SuperContainer ¶
type SuperContainer struct { LeafContainerStruct *LeafContainerStruct `path:"leaf-container-struct"` Model *Model `path:"model"` }
func (*SuperContainer) IsYANGGoStruct ¶
func (*SuperContainer) IsYANGGoStruct()
func (*SuperContainer) Validate ¶
func (*SuperContainer) Validate(opts ...ygot.ValidationOption) error
func (*SuperContainer) ΛBelongingModule ¶
func (*SuperContainer) ΛBelongingModule() string
func (*SuperContainer) ΛEnumTypeMap ¶
func (*SuperContainer) ΛEnumTypeMap() map[string][]reflect.Type
type UnionLeafType ¶
type UnionLeafType interface {
Is_UnionLeafType()
}
type UnionLeafType_EnumType ¶
type UnionLeafType_EnumType struct {
EnumType EnumType
}
func (*UnionLeafType_EnumType) Is_UnionLeafType ¶
func (*UnionLeafType_EnumType) Is_UnionLeafType()
func (*UnionLeafType_EnumType) ΛMap ¶
func (*UnionLeafType_EnumType) ΛMap() map[string]map[int64]ygot.EnumDefinition
type UnionLeafType_EnumType2 ¶
type UnionLeafType_EnumType2 struct {
EnumType2 EnumType2
}
func (*UnionLeafType_EnumType2) Is_UnionLeafType ¶
func (*UnionLeafType_EnumType2) Is_UnionLeafType()
func (*UnionLeafType_EnumType2) ΛMap ¶
func (*UnionLeafType_EnumType2) ΛMap() map[string]map[int64]ygot.EnumDefinition
type UnionLeafType_String ¶
type UnionLeafType_String struct {
String string
}
func (*UnionLeafType_String) Is_UnionLeafType ¶
func (*UnionLeafType_String) Is_UnionLeafType()
type UnionLeafType_Uint32 ¶
type UnionLeafType_Uint32 struct {
Uint32 uint32
}
func (*UnionLeafType_Uint32) Is_UnionLeafType ¶
func (*UnionLeafType_Uint32) Is_UnionLeafType()