This commit is contained in:
crusader 2018-05-11 20:53:50 +09:00
parent 0110ed7672
commit 71ce5d7095

View File

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