From 4573c99ae34530e562dc7ffcc261bd27224a71e7 Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 18 Aug 2022 00:15:46 -0700 Subject: [PATCH] fix tests --- weed/filer/filer_notify_test.go | 4 ++-- weed/pb/proto_read_write_test.go | 12 ++++++------ weed/s3api/auth_credentials_test.go | 10 +++++----- weed/shell/command_volume_list_test.go | 3 ++- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/weed/filer/filer_notify_test.go b/weed/filer/filer_notify_test.go index cf11a4bc0..4d08eb672 100644 --- a/weed/filer/filer_notify_test.go +++ b/weed/filer/filer_notify_test.go @@ -39,10 +39,10 @@ func TestProtoMarshalText(t *testing.T) { DeleteChunks: true, } - text := proto.MarshalTextString(notification) + text, _ := proto.Marshal(notification) notification2 := &filer_pb.EventNotification{} - proto.UnmarshalText(text, notification2) + proto.Unmarshal(text, notification2) if notification2.OldEntry.Chunks[0].SourceFileId != notification.OldEntry.Chunks[0].SourceFileId { t.Fatalf("marshal/unmarshal error: %s", text) diff --git a/weed/pb/proto_read_write_test.go b/weed/pb/proto_read_write_test.go index ac3b960ee..06dc136b0 100644 --- a/weed/pb/proto_read_write_test.go +++ b/weed/pb/proto_read_write_test.go @@ -16,15 +16,15 @@ func TestJsonpMarshalUnmarshal(t *testing.T) { FileSize: 12, } - m := jsonpb.Marshaler{ - EmitDefaults: true, - Indent: " ", + m := jsonpb.MarshalOptions{ + EmitUnpopulated: true, + Indent: " ", } - if text, err := m.MarshalToString(tv); err != nil { + if text, err := m.Marshal(tv); err != nil { fmt.Printf("marshal eror: %v\n", err) } else { - fmt.Printf("marshalled: %s\n", text) + fmt.Printf("marshalled: %s\n", string(text)) } rawJson := `{ @@ -34,7 +34,7 @@ func TestJsonpMarshalUnmarshal(t *testing.T) { }` tv1 := &volume_server_pb.RemoteFile{} - if err := jsonpb.UnmarshalString(rawJson, tv1); err != nil { + if err := jsonpb.Unmarshal([]byte(rawJson), tv1); err != nil { fmt.Printf("unmarshal error: %v\n", err) } diff --git a/weed/s3api/auth_credentials_test.go b/weed/s3api/auth_credentials_test.go index 09692eb81..d2fa5b216 100644 --- a/weed/s3api/auth_credentials_test.go +++ b/weed/s3api/auth_credentials_test.go @@ -58,14 +58,14 @@ func TestIdentityListFileFormat(t *testing.T) { s3ApiConfiguration.Identities = append(s3ApiConfiguration.Identities, identity2) s3ApiConfiguration.Identities = append(s3ApiConfiguration.Identities, identity3) - m := jsonpb.Marshaler{ - EmitDefaults: true, - Indent: " ", + m := jsonpb.MarshalOptions{ + EmitUnpopulated: true, + Indent: " ", } - text, _ := m.MarshalToString(s3ApiConfiguration) + text, _ := m.Marshal(s3ApiConfiguration) - println(text) + println(string(text)) } diff --git a/weed/shell/command_volume_list_test.go b/weed/shell/command_volume_list_test.go index 5da9ca49a..79c980508 100644 --- a/weed/shell/command_volume_list_test.go +++ b/weed/shell/command_volume_list_test.go @@ -4,7 +4,8 @@ import ( _ "embed" "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/stretchr/testify/assert" - "google.golang.org/protobuf/proto" + //"google.golang.org/protobuf/proto" + "github.com/golang/protobuf/proto" "strconv" "strings" "testing"