summaryrefslogtreecommitdiff
path: root/test/go
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2014-12-14 03:14:26 +0100
committerJens Geyer <jensg@apache.org>2015-01-03 17:37:54 +0100
commit8bcfdd98ae59d840b677a485b74dda3953b4bcc1 (patch)
tree659ef62202eea161ca503d7ab3250238830abc8f /test/go
parent43e195afcd4cd3db67c7343271920af147e268e6 (diff)
downloadthrift-8bcfdd98ae59d840b677a485b74dda3953b4bcc1.tar.gz
THRIFT-2886 Integrate binary type in standard Thrift cross test
Client: C_glib, C++, D, Erlang, Go, Haskell, Lua, Java/Me, JavaScript, Node, Ocaml, Perl, PHP, Python, Ruby Patch: Jens Geyer This closes #341 Minimal server-side implementations and TODO stubs for various languages to let "make check" succeeed. Not contained in this patch and still TODO: - client side implementations, i.e. calls to testBinary() and appropriate tests - server side hex printout missing for some languages
Diffstat (limited to 'test/go')
-rw-r--r--test/go/src/bin/testclient/main.go2
-rw-r--r--test/go/src/common/clientserver_test.go3
-rw-r--r--test/go/src/common/mock_handler.go11
-rw-r--r--test/go/src/common/printing_handler.go12
-rw-r--r--test/go/src/common/simple_handler.go4
5 files changed, 32 insertions, 0 deletions
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go
index 2acf6cfc0..c48df0e2f 100644
--- a/test/go/src/bin/testclient/main.go
+++ b/test/go/src/bin/testclient/main.go
@@ -107,6 +107,8 @@ func callEverything(client *thrifttest.ThriftTestClient) {
t.Fatalf("Unexpected TestDouble() result expected 42.42, got %f ", d)
}
+ // TODO: add TestBinary() call
+
xs := thrifttest.NewXtruct()
xs.StringThing = "thing"
xs.ByteThing = 42
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
index 8add0416c..3b512add4 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -92,6 +92,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
handler.EXPECT().TestByte(int8(42)).Return(int8(42), nil),
handler.EXPECT().TestI32(int32(4242)).Return(int32(4242), nil),
handler.EXPECT().TestI64(int64(424242)).Return(int64(424242), nil),
+ // TODO: add TestBinary()
handler.EXPECT().TestDouble(float64(42.42)).Return(float64(42.42), nil),
handler.EXPECT().TestStruct(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}).Return(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}, nil),
handler.EXPECT().TestNest(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}).Return(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}, nil),
@@ -156,6 +157,8 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
t.Errorf("Unexpected TestDouble() result expected 42.42, got %f ", d)
}
+ // TODO: add TestBinary() call
+
xs := thrifttest.NewXtruct()
xs.StringThing = "thing"
xs.ByteThing = 42
diff --git a/test/go/src/common/mock_handler.go b/test/go/src/common/mock_handler.go
index d736ed965..8ef3b6e98 100644
--- a/test/go/src/common/mock_handler.go
+++ b/test/go/src/common/mock_handler.go
@@ -70,6 +70,17 @@ func (_mr *_MockThriftTestRecorder) TestDouble(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "TestDouble", arg0)
}
+func (_m *MockThriftTest) TestBinary(_param0 []byte) ([]byte, error) {
+ ret := _m.ctrl.Call(_m, "TestBinary", _param0)
+ ret0, _ := ret[0].([]byte)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockThriftTestRecorder) TestBinary(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBinary", arg0)
+}
+
func (_m *MockThriftTest) TestEnum(_param0 thrifttest.Numberz) (thrifttest.Numberz, error) {
ret := _m.ctrl.Call(_m, "TestEnum", _param0)
ret0, _ := ret[0].(thrifttest.Numberz)
diff --git a/test/go/src/common/printing_handler.go b/test/go/src/common/printing_handler.go
index 6cc15078f..bed7086d8 100644
--- a/test/go/src/common/printing_handler.go
+++ b/test/go/src/common/printing_handler.go
@@ -22,6 +22,7 @@ package common
import (
"errors"
"fmt"
+ "encoding/hex"
. "gen/thrifttest"
"time"
)
@@ -91,6 +92,17 @@ func (p *printingHandler) TestDouble(thing float64) (r float64, err error) {
return thing, nil
}
+// Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data
+// @param []byte thing - the binary to print
+// @return []byte - returns the binary 'thing'
+//
+// Parameters:
+// - Thing
+func (p *printingHandler) TestBinary(thing []byte) (r []byte, err error) {
+ fmt.Printf("testBinary(%s)\n", hex.EncodeToString(thing))
+ return thing, nil
+}
+
// Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values
// @param Xtruct thing - the Xtruct to print
// @return Xtruct - returns the Xtruct 'thing'
diff --git a/test/go/src/common/simple_handler.go b/test/go/src/common/simple_handler.go
index 433616da0..97ff52d46 100644
--- a/test/go/src/common/simple_handler.go
+++ b/test/go/src/common/simple_handler.go
@@ -53,6 +53,10 @@ func (p *simpleHandler) TestDouble(thing float64) (r float64, err error) {
return thing, nil
}
+func (p *simpleHandler) TestBinary(thing []byte) (r []byte, err error) {
+ return thing, nil
+}
+
func (p *simpleHandler) TestStruct(thing *Xtruct) (r *Xtruct, err error) {
return r, err
}