aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/filer_notify_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/filer/filer_notify_test.go')
-rw-r--r--weed/filer/filer_notify_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/weed/filer/filer_notify_test.go b/weed/filer/filer_notify_test.go
new file mode 100644
index 000000000..6a2be8f18
--- /dev/null
+++ b/weed/filer/filer_notify_test.go
@@ -0,0 +1,53 @@
+package filer
+
+import (
+ "testing"
+ "time"
+
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/chrislusf/seaweedfs/weed/util"
+
+ "github.com/golang/protobuf/proto"
+)
+
+func TestProtoMarshalText(t *testing.T) {
+
+ oldEntry := &Entry{
+ FullPath: util.FullPath("/this/path/to"),
+ Attr: Attr{
+ Mtime: time.Now(),
+ Mode: 0644,
+ Uid: 1,
+ Mime: "text/json",
+ TtlSec: 25,
+ },
+ Chunks: []*filer_pb.FileChunk{
+ &filer_pb.FileChunk{
+ FileId: "234,2423423422",
+ Offset: 234234,
+ Size: 234,
+ Mtime: 12312423,
+ ETag: "2342342354",
+ SourceFileId: "23234,2342342342",
+ },
+ },
+ }
+
+ notification := &filer_pb.EventNotification{
+ OldEntry: oldEntry.ToProtoEntry(),
+ NewEntry: nil,
+ DeleteChunks: true,
+ }
+
+ text := proto.MarshalTextString(notification)
+
+ notification2 := &filer_pb.EventNotification{}
+ proto.UnmarshalText(text, notification2)
+
+ if notification2.OldEntry.Chunks[0].SourceFileId != notification.OldEntry.Chunks[0].SourceFileId {
+ t.Fatalf("marshal/unmarshal error: %s", text)
+ }
+
+ println(text)
+
+}