You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
619 B
36 lines
619 B
11 years ago
|
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")
|
||
|
}
|