Esempio n. 1
0
func TestFetch(t *testing.T) {
	os.Mkdir(TMPDIR, 0755)
	defer os.RemoveAll(TMPDIR)

	hash := avatar.HashEmail("*****@*****.**")
	a := avatar.New(hash, TMPDIR)
	a.UpdateTimeout(time.Millisecond * 200)
}
Esempio n. 2
0
// AvatarLink returns avatar link by given e-mail.
func AvatarLink(email string) string {
	if setting.DisableGravatar || setting.OfflineMode {
		return setting.AppSubUrl + "/img/avatar_default.jpg"
	}

	gravatarHash := avatar.HashEmail(email)
	if setting.Service.EnableCacheAvatar {
		return setting.AppSubUrl + "/avatar/" + gravatarHash
	}
	return setting.GravatarSource + gravatarHash
}
Esempio n. 3
0
func TestFetchMany(t *testing.T) {
	os.Mkdir(TMPDIR, 0755)
	defer os.RemoveAll(TMPDIR)

	t.Log("start")
	var n = 5
	ch := make(chan bool, n)
	for i := 0; i < n; i++ {
		go func(i int) {
			hash := avatar.HashEmail(strconv.Itoa(i) + "*****@*****.**")
			a := avatar.New(hash, TMPDIR)
			a.Update()
			t.Log("finish", hash)
			ch <- true
		}(i)
	}
	for i := 0; i < n; i++ {
		<-ch
	}
	t.Log("end")
}