blank identifier for tests
This commit is contained in:
parent
2131ac5052
commit
3e4d668990
4 changed files with 24 additions and 24 deletions
|
@ -13,24 +13,24 @@ func Tests_Bucket(t *testing.T) {
|
|||
Expectify(new(BucketTests), t)
|
||||
}
|
||||
|
||||
func (b *BucketTests) GetMissFromBucket() {
|
||||
func (_ *BucketTests) GetMissFromBucket() {
|
||||
bucket := testBucket()
|
||||
Expect(bucket.get("invalid")).To.Equal(nil)
|
||||
}
|
||||
|
||||
func (b *BucketTests) GetHitFromBucket() {
|
||||
func (_ *BucketTests) GetHitFromBucket() {
|
||||
bucket := testBucket()
|
||||
item := bucket.get("power")
|
||||
assertValue(item, "9000")
|
||||
}
|
||||
|
||||
func (b *BucketTests) DeleteItemFromBucket() {
|
||||
func (_ *BucketTests) DeleteItemFromBucket() {
|
||||
bucket := testBucket()
|
||||
bucket.delete("power")
|
||||
Expect(bucket.get("power")).To.Equal(nil)
|
||||
}
|
||||
|
||||
func (b *BucketTests) SetsANewBucketItem() {
|
||||
func (_ *BucketTests) SetsANewBucketItem() {
|
||||
bucket := testBucket()
|
||||
item, new := bucket.set("spice", TestValue("flow"), time.Minute)
|
||||
assertValue(item, "flow")
|
||||
|
@ -39,7 +39,7 @@ func (b *BucketTests) SetsANewBucketItem() {
|
|||
Expect(new).To.Equal(true)
|
||||
}
|
||||
|
||||
func (b *BucketTests) SetsAnExistingItem() {
|
||||
func (_ *BucketTests) SetsAnExistingItem() {
|
||||
bucket := testBucket()
|
||||
item, new := bucket.set("power", TestValue("9002"), time.Minute)
|
||||
assertValue(item, "9002")
|
||||
|
@ -48,13 +48,13 @@ func (b *BucketTests) SetsAnExistingItem() {
|
|||
Expect(new).To.Equal(false)
|
||||
}
|
||||
|
||||
func (b *BucketTests) ReplaceDoesNothingIfKeyDoesNotExist() {
|
||||
func (_ *BucketTests) ReplaceDoesNothingIfKeyDoesNotExist() {
|
||||
bucket := testBucket()
|
||||
Expect(bucket.replace("power", TestValue("9002"))).To.Equal(false)
|
||||
Expect(bucket.get("power")).To.Equal(nil)
|
||||
}
|
||||
|
||||
func (b *BucketTests) ReplaceReplacesThevalue() {
|
||||
func (_ *BucketTests) ReplaceReplacesThevalue() {
|
||||
bucket := testBucket()
|
||||
item, _ := bucket.set("power", TestValue("9002"), time.Minute)
|
||||
Expect(bucket.replace("power", TestValue("9004"))).To.Equal(true)
|
||||
|
|
|
@ -13,7 +13,7 @@ func Test_Cache(t *testing.T) {
|
|||
Expectify(new(CacheTests), t)
|
||||
}
|
||||
|
||||
func (c *CacheTests) DeletesAValue() {
|
||||
func (_ *CacheTests) DeletesAValue() {
|
||||
cache := New(Configure())
|
||||
cache.Set("spice", "flow", time.Minute)
|
||||
cache.Set("worm", "sand", time.Minute)
|
||||
|
@ -22,7 +22,7 @@ func (c *CacheTests) DeletesAValue() {
|
|||
Expect(cache.Get("worm").Value()).To.Equal("sand")
|
||||
}
|
||||
|
||||
func (c *CacheTests) GCsTheOldestItems() {
|
||||
func (_ *CacheTests) GCsTheOldestItems() {
|
||||
cache := New(Configure().ItemsToPrune(10))
|
||||
for i := 0; i < 500; i++ {
|
||||
cache.Set(strconv.Itoa(i), i, time.Minute)
|
||||
|
@ -34,7 +34,7 @@ func (c *CacheTests) GCsTheOldestItems() {
|
|||
Expect(cache.Get("10").Value()).To.Equal(10)
|
||||
}
|
||||
|
||||
func (c *CacheTests) PromotedItemsDontGetPruned() {
|
||||
func (_ *CacheTests) PromotedItemsDontGetPruned() {
|
||||
cache := New(Configure().ItemsToPrune(10).GetsPerPromote(1))
|
||||
for i := 0; i < 500; i++ {
|
||||
cache.Set(strconv.Itoa(i), i, time.Minute)
|
||||
|
@ -48,7 +48,7 @@ func (c *CacheTests) PromotedItemsDontGetPruned() {
|
|||
Expect(cache.Get("11").Value()).To.Equal(11)
|
||||
}
|
||||
|
||||
func (c *CacheTests) TrackerDoesNotCleanupHeldInstance() {
|
||||
func (_ *CacheTests) TrackerDoesNotCleanupHeldInstance() {
|
||||
cache := New(Configure().ItemsToPrune(10).Track())
|
||||
for i := 0; i < 10; i++ {
|
||||
cache.Set(strconv.Itoa(i), i, time.Minute)
|
||||
|
@ -63,7 +63,7 @@ func (c *CacheTests) TrackerDoesNotCleanupHeldInstance() {
|
|||
Expect(cache.Get("0")).To.Equal(nil)
|
||||
}
|
||||
|
||||
func (c *CacheTests) RemovesOldestItemWhenFull() {
|
||||
func (_ *CacheTests) RemovesOldestItemWhenFull() {
|
||||
cache := New(Configure().MaxItems(5).ItemsToPrune(1))
|
||||
for i := 0; i < 7; i++ {
|
||||
cache.Set(strconv.Itoa(i), i, time.Minute)
|
||||
|
|
10
item_test.go
10
item_test.go
|
@ -12,13 +12,13 @@ func Test_Item(t *testing.T) {
|
|||
Expectify(new(ItemTests), t)
|
||||
}
|
||||
|
||||
func (i *ItemTests) Promotability() {
|
||||
func (_ *ItemTests) Promotability() {
|
||||
item := &Item{promotions: 4}
|
||||
Expect(item.shouldPromote(5)).To.Equal(true)
|
||||
Expect(item.shouldPromote(5)).To.Equal(false)
|
||||
}
|
||||
|
||||
func (i *ItemTests) Expired() {
|
||||
func (_ *ItemTests) Expired() {
|
||||
now := time.Now().Unix()
|
||||
item1 := &Item{expires: now + 1}
|
||||
item2 := &Item{expires: now - 1}
|
||||
|
@ -26,7 +26,7 @@ func (i *ItemTests) Expired() {
|
|||
Expect(item2.Expired()).To.Equal(true)
|
||||
}
|
||||
|
||||
func (i *ItemTests) TTL() {
|
||||
func (_ *ItemTests) TTL() {
|
||||
now := time.Now().Unix()
|
||||
item1 := &Item{expires: now + 10}
|
||||
item2 := &Item{expires: now - 10}
|
||||
|
@ -34,13 +34,13 @@ func (i *ItemTests) TTL() {
|
|||
Expect(item2.TTL()).To.Equal(time.Second * -10)
|
||||
}
|
||||
|
||||
func (i *ItemTests) Expires() {
|
||||
func (_ *ItemTests) Expires() {
|
||||
now := time.Now().Unix()
|
||||
item := &Item{expires: now + 10}
|
||||
Expect(item.Expires().Unix()).To.Equal(now + 10)
|
||||
}
|
||||
|
||||
func (i *ItemTests) Extend() {
|
||||
func (_ *ItemTests) Extend() {
|
||||
item := &Item{expires: time.Now().Unix() + 10}
|
||||
item.Extend(time.Minute * 2)
|
||||
Expect(item.Expires().Unix()).To.Equal(time.Now().Unix() + 120)
|
||||
|
|
|
@ -13,19 +13,19 @@ func Test_LayeredCache(t *testing.T) {
|
|||
Expectify(new(LayeredCacheTests), t)
|
||||
}
|
||||
|
||||
func (l *LayeredCacheTests) GetsANonExistantValue() {
|
||||
func (_ *LayeredCacheTests) GetsANonExistantValue() {
|
||||
cache := newLayered()
|
||||
Expect(cache.Get("spice", "flow")).To.Equal(nil)
|
||||
}
|
||||
|
||||
func (l *LayeredCacheTests) SetANewValue() {
|
||||
func (_ *LayeredCacheTests) SetANewValue() {
|
||||
cache := newLayered()
|
||||
cache.Set("spice", "flow", "a value", time.Minute)
|
||||
Expect(cache.Get("spice", "flow").Value()).To.Equal("a value")
|
||||
Expect(cache.Get("spice", "stop")).To.Equal(nil)
|
||||
}
|
||||
|
||||
func (l *LayeredCacheTests) SetsMultipleValueWithinTheSameLayer() {
|
||||
func (_ *LayeredCacheTests) SetsMultipleValueWithinTheSameLayer() {
|
||||
cache := newLayered()
|
||||
cache.Set("spice", "flow", "value-a", time.Minute)
|
||||
cache.Set("spice", "must", "value-b", time.Minute)
|
||||
|
@ -39,13 +39,13 @@ func (l *LayeredCacheTests) SetsMultipleValueWithinTheSameLayer() {
|
|||
Expect(cache.Get("baron", "friend")).To.Equal(nil)
|
||||
}
|
||||
|
||||
func (l *LayeredCacheTests) ReplaceDoesNothingIfKeyDoesNotExist() {
|
||||
func (_ *LayeredCacheTests) ReplaceDoesNothingIfKeyDoesNotExist() {
|
||||
cache := newLayered()
|
||||
Expect(cache.Replace("spice", "flow", "value-a")).To.Equal(false)
|
||||
Expect(cache.Get("spice", "flow")).To.Equal(nil)
|
||||
}
|
||||
|
||||
func (l *LayeredCacheTests) ReplaceUpdatesTheValue() {
|
||||
func (_ *LayeredCacheTests) ReplaceUpdatesTheValue() {
|
||||
cache := newLayered()
|
||||
cache.Set("spice", "flow", "value-a", time.Minute)
|
||||
Expect(cache.Replace("spice", "flow", "value-b")).To.Equal(true)
|
||||
|
@ -53,7 +53,7 @@ func (l *LayeredCacheTests) ReplaceUpdatesTheValue() {
|
|||
//not sure how to test that the TTL hasn't changed sort of a sleep..
|
||||
}
|
||||
|
||||
func (l *LayeredCacheTests) DeletesAValue() {
|
||||
func (_ *LayeredCacheTests) DeletesAValue() {
|
||||
cache := newLayered()
|
||||
cache.Set("spice", "flow", "value-a", time.Minute)
|
||||
cache.Set("spice", "must", "value-b", time.Minute)
|
||||
|
@ -65,7 +65,7 @@ func (l *LayeredCacheTests) DeletesAValue() {
|
|||
Expect(cache.Get("leto", "sister").Value()).To.Equal("ghanima")
|
||||
}
|
||||
|
||||
func (l *LayeredCacheTests) DeletesALayer() {
|
||||
func (_ *LayeredCacheTests) DeletesALayer() {
|
||||
cache := newLayered()
|
||||
cache.Set("spice", "flow", "value-a", time.Minute)
|
||||
cache.Set("spice", "must", "value-b", time.Minute)
|
||||
|
|
Loading…
Reference in a new issue