func TestPrepare(t *testing.T) { buff.WriteString("\n\n\n========================================================\n") buff.WriteString("TestPrepare start\n\n\n") buff.WriteString("*************测试前的准备,新建测试用户,10司机账号+10个乘客账号****************\n\n\n") head := "test head" str := "/user/reg?userName=%v&mobile=%v&head=%v" for i := 0; i < 10; i++ { name := "driver" + strconv.Itoa(t.Nanosecond()) + strconv.Itoa(i) mobile := "dm" + strconv.Itoa(t.Nanosecond()) + strconv.Itoa(i) var vmap map[string]interface{} s, err := ts.G(str, name, mobile, head) vmap, _ = util.Json2Map(s) uidSlice = append(uidSlice, vmap["data"]) writeString(s, err) } for i := 0; i < 10; i++ { name := "passenger" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) mobile := "pm" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) var vmap map[string]interface{} s, err := ts.G(str, name, mobile, head) vmap, _ = util.Json2Map(s) uidSlice = append(uidSlice, vmap["data"]) writeString(s, err) } buff.WriteString("TestPrepare end\n\n\n") buff.WriteString("\n\n\n========================================================\n") }
func (a *AbsV) Build(dtcm *dtm.DTCM_S, id, info interface{}, args ...interface{}) (interface{}, interface{}, []interface{}, error) { var src = fmt.Sprintf("%v", args[0]) video, err := ParseVideo(filepath.Join(a.WDir, src)) if err != nil { err = util.Err("AbsV parse video by src(%v) error->%v", src, err) log.E("%v", err) return nil, nil, nil, err } video.Info = info video.Alias = a.Alias var mv, _ = util.Json2Map(util.S2Json(video)) var tw, th, dur = video.Width, video.Height, int64(video.Duration * 1000000) var dst interface{} if len(args) > 1 { dst = args[1] } else { dst = strings.TrimSuffix(src, filepath.Ext(src)) } log.D("AbsV adding task by src(%v),width(%v),height(%v),duration(%v)", src, tw, th, dur) return id, mv, []interface{}{ src, dst, tw, th, dur, }, nil }
func TestReg(t *testing.T) { buff.WriteString("\n\n\n========================================================\n") buff.WriteString("Test reg begin\n\n\n\n") fmt.Println("\n\n\n========================================================") fmt.Println("Test reg begin\n\n\n") ti := time.Now() buff.WriteString("*************正常参数注册****************\n") fmt.Println("*************正常参数注册****************") head := "http://e.hiphotos.baidu.com/image/h%3D200/sign=bc09df35750e0cf3bff749fb3a46f23d/2fdda3cc7cd98d102db27e16263fb80e7bec90b6.jpg" hobby := "coding!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" gender := 0 for i := 0; i < 10; i++ { str := host + "/user/reg?userName=%v&mobile=%v&head=%v" name := "c" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) mobile := "m" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) regMobileSlice = append(regMobileSlice, mobile) var vmap map[string]interface{} s, err := util.HGet(str, name, mobile, head) vmap, _ = util.Json2Map(s) uidSlice = append(uidSlice, vmap["data"]) writeString(s, err) fmt.Println(vmap, err) } for i := 0; i < 10; i++ { str := host + "/user/reg?userName=%v&mobile=%v&head=%v&gender=%d&hobby=%v" name := "d" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) mobile := "n" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) regMobileSlice = append(regMobileSlice, mobile) var vmap map[string]interface{} s, err := util.HGet(str, name, mobile, head, gender, hobby) vmap, _ = util.Json2Map(s) uidSlice = append(uidSlice, vmap["data"]) writeString(s, err) fmt.Println(vmap, err) } buff.WriteString("*************正常必要参数only注册****************\n") fmt.Println("*************正常必要参数only注册****************") for i := 0; i < 10; i++ { str := host + "/user/reg?userName=%v&mobile=%v" name := "e" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) mobile := "o" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) regMobileSlice = append(regMobileSlice, mobile) var vmap map[string]interface{} s, err := util.HGet(str, name, mobile) vmap, _ = util.Json2Map(s) uidSlice = append(uidSlice, vmap["data"]) writeString(s, err) fmt.Println(vmap, err) } buff.WriteString("*************缺省参数注册****************\n") fmt.Println("*************缺省参数注册****************") for i := 0; i < 10; i++ { str := host + "/user/reg?userName=%v" name := "f" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) vmap, err := util.HGet(str, name) writeString(vmap, err) fmt.Println(vmap, err) } for i := 0; i < 10; i++ { str := host + "/user/reg?mobile=%v" mobile := "g" + strconv.Itoa(ti.Nanosecond()) + strconv.Itoa(i) regMobileSlice = append(regMobileSlice, mobile) vmap, err := util.HGet(str, mobile) writeString(vmap, err) fmt.Println(vmap, err) } buff.WriteString("\n\n\nTest reg end\n") buff.WriteString("========================================================\n\n\n\n") fmt.Println("\n\n\nTest reg end") fmt.Println("========================================================\n\n\n") }