overflow_gateway_service/gateway/service_test.go

56 lines
1.1 KiB
Go
Raw Normal View History

2017-05-24 06:31:30 +00:00
package gateway
import (
"testing"
"reflect"
"github.com/stretchr/testify/assert"
"encoding/json"
"github.com/golang/glog"
2017-05-29 11:32:23 +00:00
"git.loafle.net/overflow/overflow_proxy_service/proxy"
2017-05-24 06:31:30 +00:00
)
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)
}