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

	hash := avatar.HashEmail("ssx205@gmail.com")
	a := avatar.New(hash, TMPDIR)
	a.UpdateTimeout(time.Millisecond * 200)
}
Example #2
0
func TestFetchMany(t *testing.T) {
	os.Mkdir(TMPDIR, 0755)
	defer os.RemoveAll(TMPDIR)

	log.Println("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) + "ssx205@gmail.com")
			a := avatar.New(hash, TMPDIR)
			a.Update()
			log.Println("finish", hash)
			ch <- true
		}(i)
	}
	for i := 0; i < n; i++ {
		<-ch
	}
	log.Println("end")
}