Documentation ¶
Index ¶
- func EqualProtos(t require.TestingT, expected, actual proto.Message)
- func Field(t require.TestingT, value interface{}, name string) *reflect.StructField
- func FieldOption(t require.TestingT, options, message proto.Message, field string)
- func FieldType(t require.TestingT, value interface{}, name string, sample interface{})
- func FileOptions(t require.TestingT, options, message proto.Message)
- func MessageOption(t require.TestingT, options, message proto.Message)
- func StructFieldTags(t require.TestingT, value interface{}, name string, tags map[string]string)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FieldOption ¶
Example ¶
package main import ( "testing" "github.com/complex64/protoc-gen-go-firestore/v2/internal/require" "github.com/complex64/protoc-gen-go-firestore/v2/internal/require/testdata" ) func main() { var t *testing.T // We're inside a test case. // message MyMessage { // string message_field = 1 [ // (testdata.field).field_option = "field option value" // ]; // } // A message, with a field as annotated above. msg := &testdata.MyMessage{} // The expected option the annotation should map to. opts := &testdata.FieldOptions{ FieldOption: "field option value", } require.FieldOption(t, opts, msg, "message_field") // Test passes. }
Output:
func FileOptions ¶
FileOptions asserts that message has options set for its protobuf message options.
Example ¶
package main import ( "testing" "github.com/complex64/protoc-gen-go-firestore/v2/internal/require" "github.com/complex64/protoc-gen-go-firestore/v2/internal/require/testdata" ) func main() { var t *testing.T // We're inside a test case. // In options.proto: // option (testdata.file).file_option = "file option value"; // message MyMessage {} // A message from options.proto which links to its parent file descriptor. msg := &testdata.MyMessage{} opts := &testdata.FileOptions{ // Assertions... } require.FileOptions(t, opts, msg) }
Output:
func MessageOption ¶
MessageOption asserts the message's parent file has options set on the file level.
Example ¶
package main import ( "testing" "github.com/complex64/protoc-gen-go-firestore/v2/internal/require" "github.com/complex64/protoc-gen-go-firestore/v2/internal/require/testdata" ) func main() { var t *testing.T // We're inside a test case. // message MyMessage { // option (testdata.message).message_option = "option value"; // ... // } // A message, annotated as shown above. msg := &testdata.MyMessage{ MessageField: "field value", } // The expected option the annotation should map to. opts := &testdata.MessageOptions{ MessageOption: "message option value", } require.MessageOption(t, opts, msg) // Test passes. }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.