Documentation ¶
Overview ¶
Package vegr (hel...vegr - the road to helheim) is a place to store library calls that hel mocks need in order to work. We put any non-trivial logic here so that it can have tests, and then allow hel mocks to import and use this properly-tested logic.
Since this is only intended for use by generated code, it eagerly panics for obviously incorrect usage.
Index ¶
- Constants
- func BlockChan() ret.Blocker
- func PopulateReturns[T any](t TestingT, timeout time.Duration, mock ReturnMethod[T], addrs ...any)
- func TupleDesc(t reflect.Type, forceParens bool, isVariadic bool, ignored ...int) string
- type EnforceVersion
- type Method
- type Option
- func Variadic() Optiondeprecated
- type ReturnMethod
- type TestingT
- type VariadicIn
Constants ¶
const ( // MinVersion is the minimum version of hel that this library can work with. // Any version below v0.{MinVersion}.0 uses legacy code that is no longer // supported in this version of vegr. MinVersion = 7 // MaxVersion is the maximum version of hel that this library can work with. // Any version above v0.{MaxVersion}.* may rely on new features in vegr that // don't exist in this version. MaxVersion = Version // Version is the current version of hel. Version = 7 )
Variables ¶
This section is empty.
Functions ¶
func BlockChan ¶ added in v0.5.0
BlockChan initializes a channel for use when a method may want to block a return.
func PopulateReturns ¶
PopulateReturns handles populating return value addresses with values from channels in a mock.
Types ¶
type EnforceVersion ¶ added in v0.6.0
type EnforceVersion uint
EnforceVersion is used by generated code to ensure that runtime code supports the version of the generated code. It relies on uint underflow to break if the version of hel that it was generated with is not supported by the imported version of this library.
The runtime can be updated with:
go get -u git.sr.ht/~nelsam/hel
The generated code can be updated with:
hel
Credit goes to github.com/protocol-buffers/protobuf-go for this idea.
type Method ¶ added in v0.7.0
type Method[T, U any] struct { // contains filtered or unexported fields }
Method is a type which can track method call arguments and return values.
func NewMethod ¶ added in v0.7.0
NewMethod creates a new method struct using buffer as the channel buffer for input and output channels.
func (Method[T, U]) In ¶ added in v0.7.0
func (m Method[T, U]) In() chan T
In returns the input channel for m.
func (Method[T, U]) Out ¶ added in v0.7.0
func (m Method[T, U]) Out() chan U
Out returns the output channel for m.
type Option ¶ added in v0.7.0
type Option func(methodPrefs) methodPrefs
Option is an option used to construct a method.
func Variadic
deprecated
added in
v0.7.0
func Variadic() Option
Variadic is used to tell vegr that a method is variadic.
Deprecated: In newer code, this is part of the type signature instead of a runtime option in. not a method is variadic is part of its input type signature instead of a runtime option. This means that in newer generated code, we can rely on Method[T, U]{}.Variadic().
type ReturnMethod ¶ added in v0.7.0
ReturnMethod represents the methods that PopulateReturns uses from a Method.
type TestingT ¶ added in v0.6.5
type TestingT interface { Helper() Failed() bool Logf(string, ...any) Fatalf(string, ...any) Cleanup(func()) }
TestingT represents the properties of *testing.T that vegr uses.
type VariadicIn ¶
type VariadicIn interface {
Variadic() bool
}
VariadicIn is a type of input struct that declares whether or not it has variadic parameters at compile time.