Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit eb50150

Browse files
committed
Merge pull request #44 from sourcegraph/stdlib-tests
Change tests to use standard library, more idiomatic style.
2 parents 4b02602 + f99d4c7 commit eb50150

File tree

5 files changed

+666
-362
lines changed

5 files changed

+666
-362
lines changed

‎diskcache/diskcache_test.go‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,38 @@ import (
55
"io/ioutil"
66
"os"
77
"testing"
8-
9-
. "gopkg.in/check.v1"
108
)
119

12-
func Test(t *testing.T) { TestingT(t) }
13-
14-
type S struct{}
15-
16-
var _ = Suite(&S{})
17-
18-
func (s *S) Test(c *C) {
10+
func TestDiskCache(t *testing.T) {
1911
tempDir, err := ioutil.TempDir("", "httpcache")
2012
if err != nil {
21-
c.Fatalf("TempDir,: %v", err)
13+
t.Fatalf("TempDir: %v", err)
2214
}
2315
defer os.RemoveAll(tempDir)
2416

2517
cache := New(tempDir)
2618

2719
key := "testKey"
2820
_, ok := cache.Get(key)
29-
30-
c.Assert(ok, Equals, false)
21+
if ok {
22+
t.Fatal("retrieved key before adding it")
23+
}
3124

3225
val := []byte("some bytes")
3326
cache.Set(key, val)
3427

3528
retVal, ok := cache.Get(key)
36-
c.Assert(ok, Equals, true)
37-
c.Assert(bytes.Equal(retVal, val), Equals, true)
29+
if !ok {
30+
t.Fatal("could not retrieve an element we just added")
31+
}
32+
if !bytes.Equal(retVal, val) {
33+
t.Fatal("retrieved a different value than what we put in")
34+
}
3835

3936
cache.Delete(key)
4037

4138
_, ok = cache.Get(key)
42-
c.Assert(ok, Equals, false)
39+
if ok {
40+
t.Fatal("deleted key still present")
41+
}
4342
}

0 commit comments

Comments
 (0)