aboutsummaryrefslogtreecommitdiffstats
path: root/modules/avatar/avatar_test.go
blob: 49f8f91f354e32c4e07734f6e71df3f60561587d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package avatar

import (
	"log"
	"strconv"
	"testing"
	"time"
)

func TestFetch(t *testing.T) {
	hash := HashEmail("ssx205@gmail.com")
	avatar := New(hash, "./")
	//avatar.Update()
	avatar.UpdateTimeout(time.Millisecond * 200)
	time.Sleep(5 * time.Second)
}

func TestFetchMany(t *testing.T) {
	log.Println("start")
	var n = 50
	ch := make(chan bool, n)
	for i := 0; i < n; i++ {
		go func(i int) {
			hash := HashEmail(strconv.Itoa(i) + "ssx205@gmail.com")
			avatar := New(hash, "./")
			avatar.Update()
			log.Println("finish", hash)
			ch <- true
		}(i)
	}
	for i := 0; i < n; i++ {
		<-ch
	}
	log.Println("end")
}