diff options
author | Nobuaki Sukegawa <nsukeg@gmail.com> | 2015-08-16 15:42:58 +0900 |
---|---|---|
committer | Henrique Mendonça <henrique@apache.org> | 2015-08-17 21:54:23 +1000 |
commit | 2fab3deb09e492cbcb2b1e4ed1c1d302787a9abd (patch) | |
tree | 0509cd21f9a3e6e8a043d7b07b42f6600644fa0a /test/go | |
parent | 738143cf36436d65c7e379351968e6e0a1f4ca3f (diff) | |
download | thrift-2fab3deb09e492cbcb2b1e4ed1c1d302787a9abd.tar.gz |
THRIFT-3296 - Go cross test does not conform to spec
Diffstat (limited to 'test/go')
-rw-r--r-- | test/go/src/bin/testclient/main.go | 43 | ||||
-rw-r--r-- | test/go/src/common/clientserver_test.go | 2 | ||||
-rw-r--r-- | test/go/src/common/printing_handler.go | 11 |
3 files changed, 51 insertions, 5 deletions
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go index 94b5c61eb..f19743a8e 100644 --- a/test/go/src/bin/testclient/main.go +++ b/test/go/src/bin/testclient/main.go @@ -192,6 +192,44 @@ func callEverything(client *thrifttest.ThriftTestClient) { t.Fatalf("Unexpected TestMapmap() result expected %#v, got %#v ", rmapmap, mapmap) } + crazy := thrifttest.NewInsanity() + crazy.UserMap = map[thrifttest.Numberz]thrifttest.UserId { + thrifttest.Numberz_FIVE: 5, + thrifttest.Numberz_EIGHT: 8, + } + truck1 := thrifttest.NewXtruct() + truck1.StringThing = "Goodbye4" + truck1.ByteThing = 4; + truck1.I32Thing = 4; + truck1.I64Thing = 4; + truck2 := thrifttest.NewXtruct() + truck2.StringThing = "Hello2" + truck2.ByteThing = 2; + truck2.I32Thing = 2; + truck2.I64Thing = 2; + crazy.Xtructs = []*thrifttest.Xtruct { + truck1, + truck2, + } + insanity, err := client.TestInsanity(crazy) + if err != nil { + t.Fatalf("Unexpected error in TestInsanity() call: ", err) + } + if !reflect.DeepEqual(crazy, insanity[1][2]) { + t.Fatalf("Unexpected TestInsanity() first result expected %#v, got %#v ", + crazy, + insanity[1][2]) + } + if !reflect.DeepEqual(crazy, insanity[1][3]) { + t.Fatalf("Unexpected TestInsanity() second result expected %#v, got %#v ", + crazy, + insanity[1][3]) + } + if len(insanity[2][6].UserMap) > 0 || len(insanity[2][6].Xtructs) > 0 { + t.Fatalf("Unexpected TestInsanity() non-empty result got %#v ", + insanity[2][6]) + } + xxsret, err := client.TestMulti(42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24)) if err != nil { t.Fatalf("Unexpected error in TestMulti() call: ", err) @@ -208,10 +246,9 @@ func callEverything(client *thrifttest.ThriftTestClient) { t.Fatalf("Unexpected TestException() result expected %#v, got %#v ", xcept, err) } - // TODO: connection is being closed on this err = client.TestException("TException") - tex, ok := err.(thrift.TApplicationException) - if err == nil || !ok || tex.TypeId() != thrift.INTERNAL_ERROR { + _, ok := err.(thrift.TApplicationException) + if err == nil || !ok { t.Fatalf("Unexpected TestException() result expected ApplicationError, got %#v ", err) } diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go index 0080ead63..a7bd46c4e 100644 --- a/test/go/src/common/clientserver_test.go +++ b/test/go/src/common/clientserver_test.go @@ -103,7 +103,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h handler.EXPECT().TestEnum(thrifttest.Numberz_TWO).Return(thrifttest.Numberz_TWO, nil), handler.EXPECT().TestTypedef(thrifttest.UserId(42)).Return(thrifttest.UserId(42), nil), handler.EXPECT().TestMapMap(int32(42)).Return(rmapmap, nil), - //not testing insanity + // TODO: not testing insanity handler.EXPECT().TestMulti(int8(42), int32(4242), int64(424242), map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24)).Return(xxs, nil), handler.EXPECT().TestException("some").Return(xcept), handler.EXPECT().TestException("TException").Return(errors.New("Just random exception")), diff --git a/test/go/src/common/printing_handler.go b/test/go/src/common/printing_handler.go index bed7086d8..8c902d1e8 100644 --- a/test/go/src/common/printing_handler.go +++ b/test/go/src/common/printing_handler.go @@ -263,7 +263,16 @@ func (p *printingHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32, // Parameters: // - Argument func (p *printingHandler) TestInsanity(argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) { - return nil, errors.New("No Insanity") + fmt.Printf("testInsanity()\n") + r = make(map[UserId]map[Numberz]*Insanity) + r[1] = map[Numberz]*Insanity { + 2: argument, + 3: argument, + } + r[2] = map[Numberz]*Insanity { + 6: NewInsanity(), + } + return } // Prints 'testMulti()' |