Documentation
¶
Index ¶
- Variables
- func Bool(fd protoreflect.FieldDescriptor, opts GenOptions) bool
- func Bytes(fd protoreflect.FieldDescriptor, opts GenOptions) []byte
- func Enum(fd protoreflect.FieldDescriptor, opts GenOptions) protoreflect.EnumNumber
- func FieldValue(fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
- func Fixed32(fd protoreflect.FieldDescriptor, opts GenOptions) uint32
- func Fixed64(fd protoreflect.FieldDescriptor, opts GenOptions) uint64
- func Float32(fd protoreflect.FieldDescriptor, opts GenOptions) float32
- func Float64(fd protoreflect.FieldDescriptor, opts GenOptions) float64
- func GoogleDuration(fd protoreflect.FieldDescriptor, opts GenOptions) *durationpb.Duration
- func GoogleTimestamp(fd protoreflect.FieldDescriptor, opts GenOptions) *timestamppb.Timestamp
- func GoogleValue(fd protoreflect.FieldDescriptor, opts GenOptions) *structpb.Value
- func Int32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
- func Int64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
- func Map(msg protoreflect.Message, fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
- func NewFauxFaker() *fauxFaker
- func NewMessage(md protoreflect.MessageDescriptor, opts GenOptions) (protoreflect.ProtoMessage, error)
- func NewMultiFaker(fakers []ProtoFaker) multiFaker
- func Repeated(msg protoreflect.Message, fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
- func SFixed32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
- func SFixed64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
- func SInt32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
- func SInt64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
- func SetDataOnMessage(msg protoreflect.ProtoMessage, opts GenOptions) error
- func String(fd protoreflect.FieldDescriptor, opts GenOptions) string
- func UInt32(fd protoreflect.FieldDescriptor, opts GenOptions) uint32
- func UInt64(fd protoreflect.FieldDescriptor, opts GenOptions) uint64
- func UninterpretedOption(opts GenOptions) *descriptorpb.UninterpretedOption
- type FieldGenOptions
- type GenOptions
- type ProtoFaker
- type StubEntry
- type StubFinder
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotFaked = errors.New("no data was faked either because there was no relevant data or the faker was just out of faker juice")
)
Functions ¶
func Bool ¶ added in v0.0.9
func Bool(fd protoreflect.FieldDescriptor, opts GenOptions) bool
Bool returns a fake boolean value given a field descriptor.
func Bytes ¶ added in v0.0.9
func Bytes(fd protoreflect.FieldDescriptor, opts GenOptions) []byte
Bytes returns a fake []byte value given a field descriptor.
func Enum ¶ added in v0.0.9
func Enum(fd protoreflect.FieldDescriptor, opts GenOptions) protoreflect.EnumNumber
func FieldValue ¶ added in v0.3.0
func FieldValue(fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
func Fixed32 ¶ added in v0.0.9
func Fixed32(fd protoreflect.FieldDescriptor, opts GenOptions) uint32
Fixed32 returns a fake fixed32 value given a field descriptor.
func Fixed64 ¶ added in v0.0.9
func Fixed64(fd protoreflect.FieldDescriptor, opts GenOptions) uint64
Fixed64 returns a fake fixed64 value given a field descriptor.
func Float32 ¶ added in v0.0.9
func Float32(fd protoreflect.FieldDescriptor, opts GenOptions) float32
Float32 returns a fake float32 value given a field descriptor.
func Float64 ¶ added in v0.0.9
func Float64(fd protoreflect.FieldDescriptor, opts GenOptions) float64
Float64 returns a fake float64 value given a field descriptor.
func GoogleDuration ¶ added in v0.0.9
func GoogleDuration(fd protoreflect.FieldDescriptor, opts GenOptions) *durationpb.Duration
GoogleDuration generates a random google.protobuf.Duration value.
func GoogleTimestamp ¶ added in v0.0.9
func GoogleTimestamp(fd protoreflect.FieldDescriptor, opts GenOptions) *timestamppb.Timestamp
GoogleTimestamp generates a random google.protobuf.Timestamp value.
func GoogleValue ¶ added in v0.0.9
func GoogleValue(fd protoreflect.FieldDescriptor, opts GenOptions) *structpb.Value
func Int32 ¶ added in v0.0.9
func Int32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
Int32 returns a fake int32 value given a field descriptor.
func Int64 ¶ added in v0.0.9
func Int64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
Int64 returns a fake int64 value given a field descriptor.
func Map ¶ added in v0.0.16
func Map(msg protoreflect.Message, fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
Map returns a fake repeated value given a field descriptor.
func NewFauxFaker ¶ added in v0.3.0
func NewFauxFaker() *fauxFaker
func NewMessage ¶ added in v0.0.10
func NewMessage(md protoreflect.MessageDescriptor, opts GenOptions) (protoreflect.ProtoMessage, error)
NewMessage creates a new message populated with fake data given a protoreflect.MessageDescriptor
Example ¶
package main
import (
"fmt"
elizav1 "buf.build/gen/go/connectrpc/eliza/protocolbuffers/go/connectrpc/eliza/v1"
"github.com/sudorandom/fauxrpc"
"google.golang.org/protobuf/encoding/protojson"
)
func main() {
msg, _ := fauxrpc.NewMessage(elizav1.File_connectrpc_eliza_v1_eliza_proto.Messages().ByName("SayResponse"), fauxrpc.GenOptions{})
b, _ := protojson.MarshalOptions{Indent: " "}.Marshal(msg)
fmt.Println(string(b))
}
func NewMultiFaker ¶ added in v0.3.0
func NewMultiFaker(fakers []ProtoFaker) multiFaker
func Repeated ¶ added in v0.0.16
func Repeated(msg protoreflect.Message, fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
Repeated returns a fake repeated value given a field descriptor.
func SFixed32 ¶ added in v0.0.9
func SFixed32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
SFixed32 returns a fake sfixedint32 value given a field descriptor.
func SFixed64 ¶ added in v0.0.9
func SFixed64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
SFixed64 returns a fake sfixed64 value given a field descriptor.
func SInt32 ¶ added in v0.0.9
func SInt32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
SInt32 returns a fake sint32 value given a field descriptor.
func SInt64 ¶ added in v0.0.9
func SInt64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
SInt64 returns a fake sint64 value given a field descriptor.
func SetDataOnMessage ¶ added in v0.0.4
func SetDataOnMessage(msg protoreflect.ProtoMessage, opts GenOptions) error
SetDataOnMessage generates fake data given a protoreflect.ProtoMessage and sets the field values.
Example ¶
package main
import (
"fmt"
"log"
elizav1 "buf.build/gen/go/connectrpc/eliza/protocolbuffers/go/connectrpc/eliza/v1"
"github.com/sudorandom/fauxrpc"
"google.golang.org/protobuf/encoding/protojson"
)
func main() {
msg := &elizav1.SayResponse{}
if err := fauxrpc.SetDataOnMessage(msg, fauxrpc.GenOptions{}); err != nil {
log.Fatalf("error: %s", err) // handle error
}
b, _ := protojson.MarshalOptions{Indent: " "}.Marshal(msg)
fmt.Println(string(b))
}
func String ¶ added in v0.0.9
func String(fd protoreflect.FieldDescriptor, opts GenOptions) string
String returns a fake string value given a field descriptor.
func UInt32 ¶ added in v0.0.9
func UInt32(fd protoreflect.FieldDescriptor, opts GenOptions) uint32
UInt32 returns a fake uint32 value given a field descriptor.
func UInt64 ¶ added in v0.0.9
func UInt64(fd protoreflect.FieldDescriptor, opts GenOptions) uint64
UInt64 returns a fake uint64 value given a field descriptor.
func UninterpretedOption ¶ added in v0.6.0
func UninterpretedOption(opts GenOptions) *descriptorpb.UninterpretedOption
UninterpretedOption generates a random google.protobuf.UninterpretedOption value.
Types ¶
type FieldGenOptions ¶ added in v0.6.0
type FieldGenOptions struct {
Message *validate.FieldRules
}
type GenOptions ¶ added in v0.0.14
type GenOptions struct {
MaxDepth int
Faker *gofakeit.Faker
Context context.Context
StubRecorder func(StubEntry)
StubFinder StubFinder
// contains filtered or unexported fields
}
func (GenOptions) GetContext ¶ added in v0.3.0
func (st GenOptions) GetContext() context.Context
func (GenOptions) WithExtraFieldConstraints ¶ added in v0.6.0
func (st GenOptions) WithExtraFieldConstraints(rules *validate.FieldRules) GenOptions
type ProtoFaker ¶ added in v0.3.0
type ProtoFaker interface {
SetDataOnMessage(msg protoreflect.ProtoMessage, opts GenOptions) error
}
type StubEntry ¶ added in v0.5.0
type StubEntry interface {
GetName() protoreflect.FullName
GetID() string
}
type StubFinder ¶ added in v0.17.0
type StubFinder interface {
FindStub(name protoreflect.FullName, faker *gofakeit.Faker) protoreflect.ProtoMessage
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
fauxrpc
command
|
|
|
example
|
|
|
generated-faux-server
module
|
|
|
generated-mocks
module
|
|
|
private
|
|
|
frontend/templates
templ: version: v0.3.960
|
templ: version: v0.3.960 |
|
frontend/templates/browser
templ: version: v0.3.960
|
templ: version: v0.3.960 |
|
frontend/templates/browser/partials
templ: version: v0.3.960
|
templ: version: v0.3.960 |
|
frontend/templates/partials
templ: version: v0.3.960
|
templ: version: v0.3.960 |
|
frontend/templates/stubs
templ: version: v0.3.960
|
templ: version: v0.3.960 |
|
testcontainers
module
|


