forked from zbx911/line-thrift-definition-file-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_test.go
85 lines (83 loc) · 1.46 KB
/
model_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"fmt"
"testing"
)
func TestFormatThriftService(t *testing.T) {
message := &TStruct{
Name: "Message",
Fields: map[int]*TField{
1: {
Name: "from",
Type: &TString{},
},
2: {
Name: "location",
Type: &TStruct{
Name: "Location",
Fields: map[int]*TField{
1: {
Name: "address",
Type: &TString{},
},
},
},
},
},
}
service := &TService{
Methods: map[string]*TMethod{
"sendMessage": {
Parameters: map[int]*TField{
1: {
Name: "reqSeq",
Type: &TString{},
},
2: {
Name: "message",
Type: message,
},
},
Response: message,
Name: "sendMessage",
Exception: &TException{
TStruct: &TStruct{
Name: "TalkException",
Fields: map[int]*TField{
1: {
Name: "errorCode",
Type: &TEnum{
Fields: map[int]*TEnumField{
0: {
Name: "ILLEGAL_ARGUMENT",
},
1: {
Name: "AUTHENTICATION_FAILED",
},
2: {
Name: "DB_FAILED",
},
},
Name: "TalkErrorCode",
},
},
2: {
Name: "reason",
Type: &TString{},
},
3: {
Name: "parameterMap",
Type: &TMap{
KeyType: &TString{},
ValueType: &TString{},
},
},
},
},
},
},
},
Name: "TalkService",
}
fmt.Println(FormatThriftService(service))
}