From 74fff30b91c1a7744d1b26aaa6226b8dab38f47a Mon Sep 17 00:00:00 2001 From: einxie Date: Sat, 6 Jun 2020 07:48:12 +0800 Subject: [PATCH] gofmt and revice test case of sequence ttl node --- constants.go | 84 ++++++++++++++++++++++++++-------------------------- structs.go | 2 +- zk_test.go | 3 +- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/constants.go b/constants.go index a5b7071d..85c7173d 100644 --- a/constants.go +++ b/constants.go @@ -12,27 +12,27 @@ const ( ) const ( - opNotify = 0 - opCreate = 1 - opDelete = 2 - opExists = 3 - opGetData = 4 - opSetData = 5 - opGetAcl = 6 - opSetAcl = 7 - opGetChildren = 8 - opSync = 9 - opPing = 11 - opGetChildren2 = 12 - opCheck = 13 - opMulti = 14 - opReconfig = 16 - opCreateContainer = 19 - opCreateTTL = 21 - opClose = -11 - opSetAuth = 100 - opSetWatches = 101 - opError = -1 + opNotify = 0 + opCreate = 1 + opDelete = 2 + opExists = 3 + opGetData = 4 + opSetData = 5 + opGetAcl = 6 + opSetAcl = 7 + opGetChildren = 8 + opSync = 9 + opPing = 11 + opGetChildren2 = 12 + opCheck = 13 + opMulti = 14 + opReconfig = 16 + opCreateContainer = 19 + opCreateTTL = 21 + opClose = -11 + opSetAuth = 100 + opSetWatches = 101 + opError = -1 // Not in protocol, used internally opWatcherEvent = -2 ) @@ -74,7 +74,7 @@ const ( const ( FlagEphemeral = 1 FlagSequence = 2 - FlagTTL = 4 + FlagTTL = 4 ) var ( @@ -194,26 +194,26 @@ const ( var ( emptyPassword = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} opNames = map[int32]string{ - opNotify: "notify", - opCreate: "create", - opCreateContainer: "createContainer", - opCreateTTL: "createTTL", - opDelete: "delete", - opExists: "exists", - opGetData: "getData", - opSetData: "setData", - opGetAcl: "getACL", - opSetAcl: "setACL", - opGetChildren: "getChildren", - opSync: "sync", - opPing: "ping", - opGetChildren2: "getChildren2", - opCheck: "check", - opMulti: "multi", - opReconfig: "reconfig", - opClose: "close", - opSetAuth: "setAuth", - opSetWatches: "setWatches", + opNotify: "notify", + opCreate: "create", + opCreateContainer: "createContainer", + opCreateTTL: "createTTL", + opDelete: "delete", + opExists: "exists", + opGetData: "getData", + opSetData: "setData", + opGetAcl: "getACL", + opSetAcl: "setACL", + opGetChildren: "getChildren", + opSync: "sync", + opPing: "ping", + opGetChildren2: "getChildren2", + opCheck: "check", + opMulti: "multi", + opReconfig: "reconfig", + opClose: "close", + opSetAuth: "setAuth", + opSetWatches: "setWatches", opWatcherEvent: "watcherEvent", } diff --git a/structs.go b/structs.go index 719efce4..387c14c1 100644 --- a/structs.go +++ b/structs.go @@ -172,7 +172,7 @@ type CreateTTLRequest struct { Data []byte Acl []ACL Flags int32 - Ttl int64 + Ttl int64 } type createResponse pathResponse diff --git a/zk_test.go b/zk_test.go index 85eacf64..27136673 100644 --- a/zk_test.go +++ b/zk_test.go @@ -134,8 +134,7 @@ func TestCreateTTL(t *testing.T) { t.Fatalf("Create returned error: %+v", err) } else if !strings.HasPrefix(p, path) { t.Fatalf("Create returned invalid path '%s' are not '%s' with sequence", p, path) - } - if data, stat, err := zk.Get(path); err != nil { + } else if data, stat, err := zk.Get(p); err != nil { t.Fatalf("Get returned error: %+v", err) } else if stat == nil { t.Fatal("Get returned nil stat")