12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package avatar_test
- import (
- "errors"
- "os"
- "strconv"
- "testing"
- "time"
- "github.com/gogits/gogs/modules/avatar"
- "github.com/gogits/gogs/modules/log"
- )
- const TMPDIR = "test-avatar"
- 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)
- }
- 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) + "ssx205@gmail.com")
- a := avatar.New(hash, TMPDIR)
- a.Update()
- t.Log("finish", hash)
- ch <- true
- }(i)
- }
- for i := 0; i < n; i++ {
- <-ch
- }
- t.Log("end")
- }
- func TestLogTrace(t *testing.T) {
- log.Trace("%v", errors.New("console log test"))
- }
|