overflow_api_server/golang/server_test.go
snoop 2f1b86fa64 added test
changed proto
2017-06-30 13:57:24 +09:00

61 lines
1.0 KiB
Go

package server_grpc
import (
"testing"
"google.golang.org/grpc"
"golang.org/x/net/context"
"io/ioutil"
)
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())
if err != nil {
t.Log(err)
}
client := NewOverflowApiServerClient(conn)
out, err := client.Exec(context.Background(), si)
if err != nil {
t.Fatal(err)
}
t.Log(out)
}