56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
|
package gateway
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"reflect"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"encoding/json"
|
||
|
"github.com/golang/glog"
|
||
|
"loafle.com/overflow/overflow_proxy_service/proxy"
|
||
|
)
|
||
|
|
||
|
func TestServices(t *testing.T) {
|
||
|
InitServices()
|
||
|
|
||
|
meb, _ := g_services["Member"]
|
||
|
|
||
|
m := make(map[string]string)
|
||
|
m["email"] = "geek@loafle.com"
|
||
|
m["pw"] = "qwer5795"
|
||
|
|
||
|
convertParam(meb, m)
|
||
|
//val := []reflect.Value{reflect.ValueOf(meb.(*proxy.MemberService))}
|
||
|
|
||
|
va := reflect.ValueOf(meb).MethodByName("Regist").Call([]reflect.Value{})
|
||
|
|
||
|
|
||
|
//reflect.ValueOf(meb).MethodByName("Read").Call(reflect.ValueOf(meb))
|
||
|
|
||
|
assert.Equal(t, 0, len(va))
|
||
|
}
|
||
|
|
||
|
func TestServiceParam(t *testing.T) {
|
||
|
|
||
|
InitServices()
|
||
|
|
||
|
meb, _ := g_services["Member"]
|
||
|
|
||
|
m := make(map[string]string)
|
||
|
m["email"] = "geek@loafle.com"
|
||
|
m["pw"] = "qwer5795"
|
||
|
|
||
|
|
||
|
paramStr, err := json.Marshal(m)
|
||
|
|
||
|
if err != nil {
|
||
|
glog.Fatal("Json Marshal Failed : ", err.Error())
|
||
|
}
|
||
|
err = json.Unmarshal(paramStr, meb)
|
||
|
if err != nil {
|
||
|
glog.Fatal("Json Unmarshal Failed : ", err.Error())
|
||
|
}
|
||
|
|
||
|
assert.ObjectsAreEqual(proxy.MemberService{}, meb)
|
||
|
}
|
||
|
|