package test import ( "fmt" "git.rtzhtech.cn/iss/public-lib/dto" "git.rtzhtech.cn/iss/public-lib/logic" "git.rtzhtech.cn/iss/public-lib/model" "testing" ) func TestAddMpInfo(t *testing.T) { l := logic.NewMpInfoLogic() in := &model.DevMpinfo{} in.Mpid = 1 in.Mpname = "Mpname" in.Zonename = "Zonename" in.Appid = 123 in.Modelid = 456 in.Deviceid = 789 for i := 0; i < 10; i++ { in.ID = 0 err := l.AddMpInfo(in) if err != nil { t.Errorf("TestAdd:%v\n", err) } } } func TestDelMpInfo(t *testing.T) { l := logic.NewMpInfoLogic() err := l.DelMpInfo(2) if err != nil { t.Errorf("TestAdd:%v\n", err) } } func TestUpdateMpInfo(t *testing.T) { l := logic.NewMpInfoLogic() in := &model.DevMpinfo{} in.ID = 3 in.Mpid = 100 in.Mpname = "Mpname3" in.Zonename = "" in.Appid = 100 in.Modelid = 100 in.Deviceid = 0 do := l.SvcCtx.DevMpinfo err := l.ModifyMpInfo(in, do.Mpid.String(), do.Appid.String(), do.Modelid.String(), do.Mpname.String()) if err != nil { t.Errorf("TestAdd:%v\n", err) } in.ID = 4 //更新全部字段 err = l.ModifyMpInfo(in) if err != nil { t.Errorf("TestAdd:%v\n", err) } } func newMpInfoReq() *dto.GetMpInfoReq { req := &dto.GetMpInfoReq{} req.Page = 2 req.Limit = 3 req.MpName = "Mpname" req.AppId = 123 return req } func TestGetMpInfo(t *testing.T) { l := logic.NewMpInfoLogic() out, err := l.GetMpInfo(newMpInfoReq()) if err != nil { t.Errorf("TestPage:%v\n", err) } fmt.Printf("total:%d\n", out.Total) for _, v := range out.List { fmt.Println(v) } } func TestGetMpInfoCount(t *testing.T) { l := logic.NewMpInfoLogic() count, err := l.GetMpInfoCount(newMpInfoReq()) if err != nil { t.Errorf("TestPage:%v\n", err) } fmt.Println(count) } func TestGetMapInfo(t *testing.T) { server := logic.NewMapInfoLogic() req := new(dto.GetMapInfoRequest) list, err := server.GetMapInfo(req) if err != nil { t.Error(err) return } t.Log(*list) t.Log(list) } func TestSaveMapInfo(t *testing.T) { server := logic.NewMapInfoLogic() req := model.MapInfo{ Stageid: "3", Index: 4, Maptype: 6, Stationid: 6, Appid: 7, } err := server.SaveMapInfo(&req) if err != nil { t.Error(err) } } func TestDelMapInfo(t *testing.T) { server := logic.NewMapInfoLogic() err := server.DelMapInfo(3) if err != nil { t.Error(err) } }