Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proto: robustify tests that compare error messages #500

Merged
merged 1 commit into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions proto/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestGetExtensionForIncompleteDesc(t *testing.T) {
Name: "a.c",
Tag: "bytes,123456790,opt",
}
ext2 := []byte{0,1,2,3,4,5,6,7}
ext2 := []byte{0, 1, 2, 3, 4, 5, 6, 7}
if err := proto.SetExtension(msg, extdesc2, ext2); err != nil {
t.Fatalf("Could not set ext2: %s", err)
}
Expand Down Expand Up @@ -479,7 +479,7 @@ func TestNilExtension(t *testing.T) {
}
if err := proto.SetExtension(msg, pb.E_Ext_More, (*pb.Ext)(nil)); err == nil {
t.Error("expected SetExtension to fail due to a nil extension")
} else if want := "proto: SetExtension called with nil value of type *test_proto.Ext"; err.Error() != want {
} else if want := fmt.Sprintf("proto: SetExtension called with nil value of type %T", new(pb.Ext)); err.Error() != want {
t.Errorf("expected error %v, got %v", want, err)
}
// Note: if the behavior of Marshal is ever changed to ignore nil extensions, update
Expand Down
5 changes: 3 additions & 2 deletions proto/text_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
package proto_test

import (
"fmt"
"math"
"testing"

Expand Down Expand Up @@ -362,7 +363,7 @@ var unMarshalTextTests = []UnmarshalTextTest{
// Missing required field
{
in: `name: "Pawel"`,
err: `proto: required field "test_proto.MyMessage.count" not set`,
err: fmt.Sprintf(`proto: required field "%T.count" not set`, MyMessage{}),
out: &MyMessage{
Name: String("Pawel"),
},
Expand All @@ -371,7 +372,7 @@ var unMarshalTextTests = []UnmarshalTextTest{
// Missing required field in a required submessage
{
in: `count: 42 we_must_go_deeper < leo_finally_won_an_oscar <> >`,
err: `proto: required field "test_proto.InnerMessage.host" not set`,
err: fmt.Sprintf(`proto: required field "%T.host" not set`, InnerMessage{}),
out: &MyMessage{
Count: Int32(42),
WeMustGoDeeper: &RequiredInnerMessage{LeoFinallyWonAnOscar: &InnerMessage{}},
Expand Down