Skip to content

Commit

Permalink
[JSON] Do not remove trailing zero character from content length.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurdej committed Aug 16, 2019
1 parent d8818e0 commit 47dfecd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (n Node) RawStatus() ([]byte, error) {
err := C.qdb_node_status(n.handle, uri, &content, &contentLength)
var output []byte
if err == 0 {
output = C.GoBytes(unsafe.Pointer(content), C.int(contentLength-1))
output = C.GoBytes(unsafe.Pointer(content), C.int(contentLength))
n.Release(unsafe.Pointer(content))
}
return output, makeErrorOrNil(err)
Expand Down Expand Up @@ -75,7 +75,7 @@ func (n Node) RawConfig() ([]byte, error) {
err := C.qdb_node_config(n.handle, uri, &content, &contentLength)
var output []byte
if err == 0 {
output = C.GoBytes(unsafe.Pointer(content), C.int(contentLength-1))
output = C.GoBytes(unsafe.Pointer(content), C.int(contentLength))
n.Release(unsafe.Pointer(content))
}
return output, makeErrorOrNil(err)
Expand Down Expand Up @@ -107,7 +107,7 @@ func (n Node) RawTopology() ([]byte, error) {
err := C.qdb_node_topology(n.handle, uri, &content, &contentLength)
var output []byte
if err == 0 {
output = C.GoBytes(unsafe.Pointer(content), C.int(contentLength-1))
output = C.GoBytes(unsafe.Pointer(content), C.int(contentLength))
n.Release(unsafe.Pointer(content))
}
return output, makeErrorOrNil(err)
Expand Down
12 changes: 6 additions & 6 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@ var _ = Describe("Tests", func() {
})

Context("Config", func() {
It("should not retrieve status with empty uri", func() {
It("should not retrieve config with empty uri", func() {
_, err = handle.Node("").Config()
Expect(err).To(HaveOccurred())
})
It("should not retrieve status with invalid uri", func() {
It("should not retrieve config with invalid uri", func() {
_, err = handle.Node("qdb://127.0.0.1:36321").Config()
Expect(err).To(HaveOccurred())
})
It("should retrieve status with valid uri", func() {
It("should retrieve config with valid uri", func() {
config, err := handle.Node(insecureURI).Config()
Expect(err).ToNot(HaveOccurred())
Expect(config.Local.Depot.RocksDB.Root).To(Equal("insecure/db"))
})
})

Context("Topology", func() {
It("should not retrieve status with empty uri", func() {
It("should not retrieve topology with empty uri", func() {
_, err = handle.Node("").Topology()
Expect(err).To(HaveOccurred())
})
It("should not retrieve status with invalid uri", func() {
It("should not retrieve topology with invalid uri", func() {
_, err = handle.Node("qdb://127.0.0.1:36321").Topology()
Expect(err).To(HaveOccurred())
})
It("should retrieve status with valid uri", func() {
It("should retrieve topology with valid uri", func() {
topology, err := handle.Node(insecureURI).Topology()
Expect(err).ToNot(HaveOccurred())
Expect(topology.Successor.Endpoint).To(Equal(topology.Predecessor.Endpoint))
Expand Down

0 comments on commit 47dfecd

Please sign in to comment.