Skip to content

Commit

Permalink
调整单测执行命令
Browse files Browse the repository at this point in the history
  • Loading branch information
FishGoddess committed Jan 13, 2024
1 parent a2453a4 commit e69b941
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 66 deletions.
7 changes: 5 additions & 2 deletions FUTURE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
## ✒ 未来版本的新特性 (Features in future versions)

### v0.6.x

* [ ] 梳理代码,优化代码风格,精简部分代码和注释
* [ ] 完善监控上报器,提供更多缓存信息查询的方法

### v0.5.x

* [ ] ~~提供一个清空并设置全量值的方法,方便定时数据的全量替换~~
目前还找不到一个合适的设计去加入这个功能,并且也不是非常刚需,通过业务手段可以处理,所以先不加
* [ ] 完善监控上报器,提供更多缓存信息查询的方法
* [ ] 梳理代码,优化代码风格

### v0.4.x

Expand Down
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## ✒ 历史版本的特性介绍 (Features in old versions)

### v0.6.0-alpha

> 此版本发布于 2024-01-13
* 受小徒弟的建议,进行 Loader 代码的调整
* 把 cache 结构去掉,精简这部分设计

### v0.5.0

> 此版本发布于 2023-11-30
Expand Down
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Go Doc](_icons/godoc.svg)](https://pkg.go.dev/github.com/FishGoddess/cachego)
[![License](_icons/license.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![License](_icons/coverage.svg)](_icons/coverage.svg)
[![Coverage](_icons/coverage.svg)](_icons/coverage.svg)
![Test](https://github.com/FishGoddess/cachego/actions/workflows/test.yml/badge.svg)

**cachego** is an api friendly memory-based cache for [GoLang](https://golang.org) applications.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Go Doc](_icons/godoc.svg)](https://pkg.go.dev/github.com/FishGoddess/cachego)
[![License](_icons/license.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![License](_icons/coverage.svg)](_icons/coverage.svg)
[![Coverage](_icons/coverage.svg)](_icons/coverage.svg)
![Test](https://github.com/FishGoddess/cachego/actions/workflows/test.yml/badge.svg)

**cachego** 是一个拥有分片机制的轻量级内存缓存库,API 友好,支持多种数据淘汰机制,可以应用于所有的 [GoLang](https://golang.org) 应用程序中。
Expand Down
4 changes: 2 additions & 2 deletions _icons/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func testCacheImplement(t *testing.T, cache Cache) {
}
}

// go test -v -cover=^TestNewCache$
// go test -v -cover -count=1 -test.cpu=1=^TestNewCache$
func TestNewCache(t *testing.T) {
cache := NewCache()

Expand Down Expand Up @@ -296,7 +296,7 @@ func TestNewCache(t *testing.T) {
cache = NewCache(WithLRU(0))
}

// go test -v -cover=^TestNewCacheWithReport$
// go test -v -cover -count=1 -test.cpu=1=^TestNewCacheWithReport$
func TestNewCacheWithReport(t *testing.T) {
cache, reporter := NewCacheWithReport()

Expand All @@ -314,7 +314,7 @@ func TestNewCacheWithReport(t *testing.T) {
}
}

// go test -v -cover=^TestRunGCTask$
// go test -v -cover -count=1 -test.cpu=1=^TestRunGCTask$
func TestRunGCTask(t *testing.T) {
cache := new(testCache)

Expand Down
2 changes: 1 addition & 1 deletion cache_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package cachego

import "testing"

// go test -v -cover -run=^TestCacheType$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestCacheType$
func TestCacheType(t *testing.T) {
if standard.String() != string(standard) {
t.Fatalf("standard.String() %s is wrong", standard.String())
Expand Down
2 changes: 1 addition & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func isConfigEquals(conf1 *config, conf2 *config) bool {
return true
}

// go test -v -cover -run=^TestApplyOptions$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestApplyOptions$
func TestApplyOptions(t *testing.T) {
got := &config{
shardings: 0,
Expand Down
4 changes: 2 additions & 2 deletions entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
testDurationGap = 10 * time.Microsecond
)

// go test -v -cover -run=^TestNewEntry$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestNewEntry$
func TestNewEntry(t *testing.T) {
e := newEntry("key", "value", 0, now)

Expand Down Expand Up @@ -69,7 +69,7 @@ func TestNewEntry(t *testing.T) {
}
}

// go test -v -cover -run=^TestEntrySetup$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestEntrySetup$
func TestEntrySetup(t *testing.T) {
e := newEntry("key", "value", 0, now)

Expand Down
8 changes: 4 additions & 4 deletions global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ func BenchmarkHash(b *testing.B) {
}
}

// go test -v -cover -run=^TestHash$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestHash$
func TestHash(t *testing.T) {
hash := hash("test")
if hash < 0 {
t.Fatalf("hash %d <= 0", hash)
}
}

// go test -v -cover -run=^TestNow$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestNow$
func TestNow(t *testing.T) {
got := now()
expect := time.Now().UnixNano()
Expand All @@ -47,7 +47,7 @@ func TestNow(t *testing.T) {
}
}

// go test -v -cover -run=^TestSetMapInitialCap$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestSetMapInitialCap$
func TestSetMapInitialCap(t *testing.T) {
oldInitialCap := mapInitialCap

Expand All @@ -67,7 +67,7 @@ func TestSetMapInitialCap(t *testing.T) {
}
}

// go test -v -cover -run=^TestSetSliceInitialCap$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestSetSliceInitialCap$
func TestSetSliceInitialCap(t *testing.T) {
oldInitialCap := sliceInitialCap

Expand Down
6 changes: 3 additions & 3 deletions lfu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func newTestLFUCache() *lfuCache {
return newLFUCache(conf).(*lfuCache)
}

// go test -v -cover -run=^TestLFUCache$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestLFUCache$
func TestLFUCache(t *testing.T) {
cache := newTestLFUCache()
testCacheImplement(t, cache)
}

// go test -v -cover -run=^TestLFUCacheEvict$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestLFUCacheEvict$
func TestLFUCacheEvict(t *testing.T) {
cache := newTestLFUCache()

Expand Down Expand Up @@ -85,7 +85,7 @@ func TestLFUCacheEvict(t *testing.T) {
}
}

// go test -v -cover -run=^TestLFUCacheEvictSimulate$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestLFUCacheEvictSimulate$
func TestLFUCacheEvictSimulate(t *testing.T) {
cache := newTestLFUCache()

Expand Down
4 changes: 2 additions & 2 deletions load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (tlc *testLoadCache) Load(key string, ttl time.Duration, load func() (value
return tlc.loader.Load(key, ttl, load)
}

// go test -v -cover -run=^TestNewLoader$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestNewLoader$
func TestNewLoader(t *testing.T) {
loader := NewLoader(false)
if loader.group != nil {
Expand All @@ -80,7 +80,7 @@ func TestNewLoader(t *testing.T) {
}
}

// go test -v -cover -run=^TestLoaderLoad$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestLoaderLoad$
func TestLoaderLoad(t *testing.T) {
cache := newTestLoadCache(false)
loadCount := 0
Expand Down
6 changes: 3 additions & 3 deletions lru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ func newTestLRUCache() *lruCache {
return newLRUCache(conf).(*lruCache)
}

// go test -v -cover -run=^TestLRUCache$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestLRUCache$
func TestLRUCache(t *testing.T) {
cache := newTestLRUCache()
testCacheImplement(t, cache)
}

// go test -v -cover -run=^TestLRUCacheEvict$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestLRUCacheEvict$
func TestLRUCacheEvict(t *testing.T) {
cache := newTestLRUCache()

Expand Down Expand Up @@ -74,7 +74,7 @@ func TestLRUCacheEvict(t *testing.T) {
}
}

// go test -v -cover -run=^TestLRUCacheEvictSimulate$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestLRUCacheEvictSimulate$
func TestLRUCacheEvictSimulate(t *testing.T) {
cache := newTestLRUCache()

Expand Down
36 changes: 18 additions & 18 deletions option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"time"
)

// go test -v -cover -run=^TestWithCacheName$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithCacheName$
func TestWithCacheName(t *testing.T) {
got := &config{cacheName: ""}
expect := &config{cacheName: "-"}
Expand All @@ -30,7 +30,7 @@ func TestWithCacheName(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithLRU$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithLRU$
func TestWithLRU(t *testing.T) {
got := &config{cacheType: standard, maxEntries: 0}
expect := &config{cacheType: lru, maxEntries: 666}
Expand All @@ -41,7 +41,7 @@ func TestWithLRU(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithLFU$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithLFU$
func TestWithLFU(t *testing.T) {
got := &config{cacheType: standard, maxEntries: 0}
expect := &config{cacheType: lfu, maxEntries: 999}
Expand All @@ -52,7 +52,7 @@ func TestWithLFU(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithShardings$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithShardings$
func TestWithShardings(t *testing.T) {
got := &config{shardings: 0}
expect := &config{shardings: 1024}
Expand All @@ -63,7 +63,7 @@ func TestWithShardings(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithDisableSingleflight$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithDisableSingleflight$
func TestWithDisableSingleflight(t *testing.T) {
got := &config{singleflight: true}
expect := &config{singleflight: false}
Expand All @@ -74,7 +74,7 @@ func TestWithDisableSingleflight(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithGC$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithGC$
func TestWithGC(t *testing.T) {
got := &config{gcDuration: 0}
expect := &config{gcDuration: 1024}
Expand All @@ -85,7 +85,7 @@ func TestWithGC(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithMaxScans$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithMaxScans$
func TestWithMaxScans(t *testing.T) {
got := &config{maxScans: 0}
expect := &config{maxScans: 1024}
Expand All @@ -96,7 +96,7 @@ func TestWithMaxScans(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithMaxEntries$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithMaxEntries$
func TestWithMaxEntries(t *testing.T) {
got := &config{maxEntries: 0}
expect := &config{maxEntries: 1024}
Expand All @@ -107,7 +107,7 @@ func TestWithMaxEntries(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithNow$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithNow$
func TestWithNow(t *testing.T) {
now := func() int64 {
return 0
Expand All @@ -122,7 +122,7 @@ func TestWithNow(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithHash$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithHash$
func TestWithHash(t *testing.T) {
hash := func(key string) int {
return 0
Expand All @@ -137,7 +137,7 @@ func TestWithHash(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithRecordMissed$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithRecordMissed$
func TestWithRecordMissed(t *testing.T) {
got := &config{recordMissed: false}
expect := &config{recordMissed: true}
Expand All @@ -148,7 +148,7 @@ func TestWithRecordMissed(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithRecordHit$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithRecordHit$
func TestWithRecordHit(t *testing.T) {
got := &config{recordHit: false}
expect := &config{recordHit: true}
Expand All @@ -159,7 +159,7 @@ func TestWithRecordHit(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithRecordGC$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithRecordGC$
func TestWithRecordGC(t *testing.T) {
got := &config{recordGC: false}
expect := &config{recordGC: true}
Expand All @@ -170,7 +170,7 @@ func TestWithRecordGC(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithRecordLoad$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithRecordLoad$
func TestWithRecordLoad(t *testing.T) {
got := &config{recordLoad: false}
expect := &config{recordLoad: true}
Expand All @@ -181,7 +181,7 @@ func TestWithRecordLoad(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithReportMissed$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithReportMissed$
func TestWithReportMissed(t *testing.T) {
reportMissed := func(reporter *Reporter, key string) {}

Expand All @@ -194,7 +194,7 @@ func TestWithReportMissed(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithReportHit$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithReportHit$
func TestWithReportHit(t *testing.T) {
reportHit := func(reporter *Reporter, key string, value interface{}) {}

Expand All @@ -207,7 +207,7 @@ func TestWithReportHit(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithReportGC$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithReportGC$
func TestWithReportGC(t *testing.T) {
reportGC := func(reporter *Reporter, cost time.Duration, cleans int) {}

Expand All @@ -220,7 +220,7 @@ func TestWithReportGC(t *testing.T) {
}
}

// go test -v -cover -run=^TestWithReportLoad$
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithReportLoad$
func TestWithReportLoad(t *testing.T) {
reportLoad := func(reporter *Reporter, key string, value interface{}, ttl time.Duration, err error) {}

Expand Down
Loading

0 comments on commit e69b941

Please sign in to comment.