Adds test timing
This commit is contained in:
@@ -4,9 +4,8 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
@@ -24,16 +23,12 @@ func (g *errorGetter) Get(URL string) (*http.Response, error) {
|
||||
}
|
||||
|
||||
func (s *AlbumCoverCacheSuite) TestCanFetchCache(c *C) {
|
||||
tmpdir, err := ioutil.TempDir("", "satbdexplorer-tests-cache")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
cache, err := NewAlbumCoverCache(tmpdir, 10, 10*time.Second)
|
||||
cache, err := NewAlbumCoverCache(c.MkDir(), 10, 10*time.Second)
|
||||
cache.getter = testGetter
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
var resData = []bytes.Buffer{}
|
||||
|
||||
start := time.Now()
|
||||
for _, a := range albumsDataTest {
|
||||
cover, err := cache.GetCover(&a)
|
||||
var buf bytes.Buffer
|
||||
@@ -69,5 +64,5 @@ func (s *AlbumCoverCacheSuite) TestCanFetchCache(c *C) {
|
||||
c.Check(cover, IsNil)
|
||||
c.Check(err, ErrorMatches, "I will always have an error")
|
||||
}
|
||||
|
||||
log.Printf("%s: %s", c.TestName(), time.Since(start))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package main
|
||||
|
||||
import . "gopkg.in/check.v1"
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
type AlbumDescriptionGetterSuite struct {
|
||||
g *AlbumDescriptionGetter
|
||||
@@ -13,7 +18,7 @@ func (s *AlbumDescriptionGetterSuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *AlbumDescriptionGetterSuite) TestGet(c *C) {
|
||||
|
||||
start := time.Now()
|
||||
for _, a := range albumsDataTest {
|
||||
aStripped := StripNonCsvField(a)
|
||||
if c.Check(s.g.Get(&aStripped), IsNil) == true {
|
||||
@@ -21,4 +26,5 @@ func (s *AlbumDescriptionGetterSuite) TestGet(c *C) {
|
||||
c.Check(aStripped, DeepEquals, a)
|
||||
}
|
||||
}
|
||||
log.Printf("%s: %s", c.TestName(), time.Since(start))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user