1/* 2 * Copyright (c) Facebook, Inc. and its affiliates. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package gotest 18 19import ( 20 "context" 21 "thrift/test/go/if/thrifttest" 22) 23 24type testHandler struct { 25 ReturnError error 26} 27 28func (t *testHandler) DoTestVoid(ctx context.Context) error { 29 return t.ReturnError 30} 31 32func (t *testHandler) DoTestString(ctx context.Context, thing string) (string, error) { 33 return thing, t.ReturnError 34} 35 36func (t *testHandler) DoTestByte(ctx context.Context, thing int8) (int8, error) { 37 return thing, t.ReturnError 38} 39 40func (t *testHandler) DoTestI32(ctx context.Context, thing int32) (int32, error) { 41 return thing, t.ReturnError 42} 43 44func (t *testHandler) DoTestI64(ctx context.Context, thing int64) (int64, error) { 45 return thing, t.ReturnError 46} 47 48func (t *testHandler) DoTestDouble(ctx context.Context, thing float64) (float64, error) { 49 return thing, t.ReturnError 50} 51 52func (t *testHandler) DoTestFloat(ctx context.Context, thing float32) (float32, error) { 53 return thing, t.ReturnError 54} 55 56func (t *testHandler) DoTestStruct(ctx context.Context, thing *thrifttest.Xtruct) (*thrifttest.Xtruct, error) { 57 return thing, t.ReturnError 58} 59 60func (t *testHandler) DoTestNest(ctx context.Context, thing *thrifttest.Xtruct2) (*thrifttest.Xtruct2, error) { 61 return thing, t.ReturnError 62} 63 64func (t *testHandler) DoTestMap(ctx context.Context, thing map[int32]int32) (map[int32]int32, error) { 65 return thing, t.ReturnError 66} 67 68func (t *testHandler) DoTestSet(ctx context.Context, thing []int32) ([]int32, error) { 69 return thing, t.ReturnError 70} 71 72func (t *testHandler) DoTestList(ctx context.Context, thing []int32) ([]int32, error) { 73 return thing, t.ReturnError 74} 75 76func (t *testHandler) DoTestEnum(ctx context.Context, thing thrifttest.Numberz) (thrifttest.Numberz, error) { 77 return thing, t.ReturnError 78} 79 80func (t *testHandler) DoTestTypedef(ctx context.Context, thing thrifttest.UserId) (thrifttest.UserId, error) { 81 return thing, t.ReturnError 82} 83 84func (t *testHandler) DoTestMapMap(ctx context.Context, hello int32) (map[int32]map[int32]int32, error) { 85 res := map[int32]map[int32]int32{} 86 for i := int32(0); i < hello; i++ { 87 res[i] = map[int32]int32{i: i} 88 } 89 return res, t.ReturnError 90} 91 92func (t *testHandler) DoTestInsanity(ctx context.Context, argument *thrifttest.Insanity) (map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity, error) { 93 ret := map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity{} 94 ret[thrifttest.UserId(3)] = map[thrifttest.Numberz]*thrifttest.Insanity{ 95 thrifttest.Numberz_EIGHT: argument, 96 } 97 return ret, t.ReturnError 98} 99 100func (t *testHandler) DoTestMulti( 101 ctx context.Context, 102 arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, 103 arg4 thrifttest.Numberz, arg5 thrifttest.UserId, 104) (*thrifttest.Xtruct, error) { 105 xs := thrifttest.NewXtruct() 106 xs.ByteThing = arg0 107 xs.I32Thing = arg1 108 xs.I64Thing = arg2 109 return xs, t.ReturnError 110} 111 112func (t *testHandler) DoTestException(ctx context.Context, arg string) error { 113 return t.ReturnError 114} 115 116func (t *testHandler) DoTestMultiException(ctx context.Context, arg0, arg1 string) (*thrifttest.Xtruct, error) { 117 xs := thrifttest.NewXtruct() 118 xs.StringThing = arg0 119 return xs, t.ReturnError 120} 121 122func (t *testHandler) DoTestOneway(ctx context.Context, secondsToSleep int32) error { 123 return t.ReturnError 124} 125 126func (t *testHandler) XDoTestPoorName(ctx context.Context) error { 127 return t.ReturnError 128} 129