Exemplo n.º 1
0
func (self *FopImgExif) doTestImgExif(downloadUrl string) (msg string, err error) {
	begin := time.Now()
	url := downloadUrl + "exif"
	netBuf, err := util.DoHttpGet(url)
	var TargetExif ImgExif
	json.Unmarshal(netBuf.Bytes(), &TargetExif)
	if self.SrcExif != TargetExif {
		err = errors.New("Umatched Exif!")
	}
	end := time.Now()
	duration := end.Sub(begin)
	msg = util.GenLogEx("Fp    "+self.Env.Id+"_"+self.Name+"_doTestImgOp", begin, end, duration)
	if err != nil {
		return
	}
	return
}
Exemplo n.º 2
0
func (self *FopImgInfo) doTestGetImgInfo(downloadUrl string) (msg string, err error) {
	begin := time.Now()
	url := downloadUrl + "imageInfo"
	netBuf, err := util.DoHttpGet(url)
	end := time.Now()
	duration := end.Sub(begin)
	msg = util.GenLogEx("Fp    "+self.Env.Id+"_"+self.Name+"_doTestGetImgInfo", begin, end, duration)
	if err != nil {
		return
	}

	var serImgInfo ImageInfo
	json.Unmarshal(netBuf.Bytes(), &serImgInfo)
	locImgInfo := self.TargetImgInfo

	if err = CheckImgInfo(serImgInfo, locImgInfo); err != nil {
		return
	}
	return
}
Exemplo n.º 3
0
func (self *FopImgOp) doTestImgOp(downloadUrl string) (msg string, err error) {
	begin := time.Now()
	url := downloadUrl + self.Op
	netBuf, err := util.DoHttpGet(url)
	end := time.Now()
	duration := end.Sub(begin)
	msg = util.GenLogEx("Fp    "+self.Env.Id+"_"+self.Name+"_doTestImgOp", begin, end, duration)
	if err != nil {
		return
	}
	targetFile, err := os.Open(self.TargetImg)
	if err != nil {
		return
	}
	_, err = util.CheckImg(netBuf, targetFile)
	if err != nil {
		return
	}

	return
}
Exemplo n.º 4
0
Arquivo: put.go Projeto: shtlee/qa
func (self *PutFile) doTestCheckSha1(url string) (msg string, err error) {
	begin := time.Now()
	netBuf, err := util.DoHttpGet(url)
	end := time.Now()
	duration := end.Sub(begin)
	msg = util.GenLogEx("RS    "+self.Env.Id+"_"+self.Name+"_doTestIoDownload", begin, end, duration)
	if err != nil {
		return
	}

	h := sha1.New()
	_, err = io.Copy(h, netBuf)
	if err != nil {
		return
	}
	sha1Code := hex.EncodeToString(h.Sum(nil))
	if self.Sha1 != sha1Code {
		err = errors.New("check sha1 failed!")
	}
	return
}