package admin import ( "context" "gd_admin/apis" "encoding/json" "testing" ) var id int64 func Test_AdminRegister(t *testing.T) { req := apis.AdminRegisterReq{ AdminName: "test1", AdminPasswd: "admin", AdminPhone: "", AdminEmail: "", GroupId: 1, NodeId: "1,2,3,4,5", } reply := apis.AdminRegisterReply{} if err := xcli.Call(context.Background(), "AdminRegister", req, &reply); err != nil { t.Error("failed to call: ", err) } else { d, _ := json.Marshal(reply) t.Log(string(d)) } } func Test_AdminLogin(t *testing.T) { req := apis.AdminLoginReq{AdminName: "admin", AdminPasswd: "zaq12EDC"} reply := apis.AdminLoginReply{} if err := xcli.Call(context.Background(), "AdminLogin", req, &reply); err != nil { t.Error("failed to call: ", err) } else { d, _ := json.Marshal(reply) t.Log(string(d)) id = reply.AdminId } } func Test_AdminModify(t *testing.T) { req := apis.AdminModifyReq{ AdminId: 14, AdminPasswd: "123456", AdminPhone: "18000000000", AdminEmail: "", GroupId: 1, NodeId: "1,2,3,4,5,6,7", } reply := apis.AdminModifyReply{} if err := xcli.Call(context.Background(), "AdminModify", req, &reply); err != nil { t.Error("failed to call: ", err) } else { d, _ := json.Marshal(reply) t.Log(string(d)) } } func Test_AdminGetAll(t *testing.T) { req := apis.AdminGetAllReq{ Search: "ep", } reply := apis.AdminGetAllReply{} if err := xcli.Call(context.Background(), "AdminGetAll", req, &reply); err != nil { t.Error("failed to call: ", err) } else { d, _ := json.Marshal(reply) t.Log(string(d)) } } func Test_AdminDelete(t *testing.T) { req := apis.AdminDeleteReq{AdminId: id} reply := apis.AdminDeleteReply{} if err := xcli.Call(context.Background(), "AdminDelete", req, &reply); err != nil { t.Error("failed to call: ", err) } else { d, _ := json.Marshal(reply) t.Log(string(d)) } } func Test_UpdateStatus(t *testing.T) { req := apis.UpdateStatusReq{AdminId: 5} reply := apis.UpdateStatusReply{} if err := xcli.Call(context.Background(), "UpdateAdminStatus", req, &reply); err != nil { t.Error("failed to call: ", err) } else { d, _ := json.Marshal(reply) t.Log(string(d)) } } func Test_GetInfo(t *testing.T) { req := apis.GetInfoReq{Uid: 14} reply := apis.GetInfoReply{} if err := xcli.Call(context.Background(), "GetInfo", req, &reply); err != nil { t.Error("failed to call: ", err) } else { d, _ := json.Marshal(reply) t.Log(string(d)) } }