added test

changed proto
This commit is contained in:
snoop 2017-06-30 13:57:24 +09:00
parent 0b3b63295e
commit 2f1b86fa64
2 changed files with 56 additions and 34 deletions

View File

@ -35,9 +35,9 @@ var _ = math.Inf
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type ServerInput struct {
Target string `protobuf:"bytes,1,opt,name=target" json:"target,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method" json:"method,omitempty"`
Params []*ServerParam `protobuf:"bytes,3,rep,name=params" json:"params,omitempty"`
Target string `protobuf:"bytes,1,opt,name=target" json:"target,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method" json:"method,omitempty"`
Params []string `protobuf:"bytes,3,rep,name=params" json:"params,omitempty"`
}
func (m *ServerInput) Reset() { *m = ServerInput{} }
@ -59,7 +59,7 @@ func (m *ServerInput) GetMethod() string {
return ""
}
func (m *ServerInput) GetParams() []*ServerParam {
func (m *ServerInput) GetParams() []string {
if m != nil {
return m.Params
}
@ -195,21 +195,20 @@ var _OverflowApiServer_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("server_grpc.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 249 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xbf, 0x4e, 0xc3, 0x30,
0x10, 0x87, 0x31, 0xa9, 0x22, 0xb8, 0x86, 0xa1, 0x1e, 0x20, 0x62, 0x40, 0x91, 0x05, 0x28, 0x93,
0x87, 0xb2, 0xb1, 0x01, 0x13, 0x53, 0xab, 0x30, 0x31, 0x21, 0xe3, 0x5e, 0x4b, 0x24, 0xa7, 0xb6,
0x9c, 0x4b, 0x81, 0x37, 0xe0, 0xb1, 0x51, 0x6c, 0x17, 0xd1, 0xed, 0x7e, 0x9f, 0xe5, 0xef, 0xfe,
0xc0, 0xac, 0x47, 0xbf, 0x43, 0xff, 0xb6, 0xf1, 0x4e, 0x4b, 0xe7, 0x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x17, 0x36,
0xb2, 0xd4, 0x3b, 0xbf, 0xbe, 0x38, 0xd5, 0xbb, 0x45, 0x75, 0xf0, 0x70, 0x09, 0xe7, 0x0d, 0x75,
0xda, 0x92, 0x59, 0x59, 0xd4, 0x94, 0x33, 0xda, 0xb8, 0x76, 0x2e, 0x7e, 0x84, 0x78, 0x1f, 0xc7,
0xe3, 0xdd, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x11, 0xfd, 0x20, 0xaf, 0x51, 0x01, 0x00, 0x00,
}

View File

@ -4,9 +4,44 @@ import (
"testing"
"google.golang.org/grpc"
"golang.org/x/net/context"
"io/ioutil"
)
func TestRPC(t *testing.T) {
func TestTarDis_saveAllTarget(t *testing.T) {
contents,_ := ioutil.ReadFile("../dh.json")
si := &ServerInput{}
si.Target = "TargetDiscoveryService"
si.Method = "saveAllTarget"
si.Params = append(si.Params, string(contents))
si.Params = append(si.Params, "{\"id\":1}")
callRPC(t, si)
}
func TestRPCNP_readAllByDomain(t *testing.T) {
si := &ServerInput{}
si.Target = "NoAuthProbeService"
si.Method = "readAllByDomain"
//sp := &ServerParam{}
//sp.IsCollection = false
//sp.Type = "com.loafle.overflow.module.domain.model.Domain"
//sp.Data = "{\"id\":1}"
si.Params = append(si.Params, "{\"id\":1}")
callRPC(t, si)
}
func callRPC(t *testing.T, si *ServerInput) {
conn, err := grpc.Dial(":50006", grpc.WithInsecure())
@ -16,18 +51,6 @@ func TestRPC(t *testing.T) {
client := NewOverflowApiServerClient(conn)
si := &ServerInput{}
si.Target = "noauthProbe"
si.Method = "readAllByDomain"
sp := &ServerParam{}
sp.IsCollection = false
sp.Type = "com.loafle.overflow.module.domain.model.Domain"
sp.Data = "{\"id\":1}"
si.Params = append(si.Params, sp)
out, err := client.Exec(context.Background(), si)
if err != nil {
t.Fatal(err)