Пример #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)
}
Пример #2
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")
}