diff --git a/pkg/cache/memcache/main_test.go b/pkg/cache/memcache/main_test.go index 5d40535a6..064dafd9b 100644 --- a/pkg/cache/memcache/main_test.go +++ b/pkg/cache/memcache/main_test.go @@ -1,13 +1,15 @@ package memcache import ( + "flag" "log" "os" "testing" "time" - "github.com/bilibili/kratos/pkg/container/pool" - xtime "github.com/bilibili/kratos/pkg/time" + "go-common/library/container/pool" + "go-common/library/testing/lich" + xtime "go-common/library/time" ) var testConnASCII Conn @@ -68,12 +70,12 @@ func setupTestPool(addr string) { } func TestMain(m *testing.M) { - testMemcacheAddr = os.Getenv("TEST_MEMCACHE_ADDR") - if testExampleAddr == "" { - log.Print("TEST_MEMCACHE_ADDR not provide skip test.") - // ignored test. - os.Exit(0) + flag.Set("f", "./test/docker-compose.yaml") + flag.Parse() + if err := lich.Setup(); err != nil { + panic(err) } + testMemcacheAddr = "127.0.0.1:11211" setupTestConnASCII(testMemcacheAddr) setupTestMemcache(testMemcacheAddr) setupTestPool(testMemcacheAddr) @@ -81,5 +83,6 @@ func TestMain(m *testing.M) { testExampleAddr = testMemcacheAddr ret := m.Run() + lich.Teardown() os.Exit(ret) } diff --git a/pkg/cache/memcache/test/docker-compose.yaml b/pkg/cache/memcache/test/docker-compose.yaml new file mode 100755 index 000000000..ace3ebedf --- /dev/null +++ b/pkg/cache/memcache/test/docker-compose.yaml @@ -0,0 +1,9 @@ +version: "3.7" + +services: + mc: + image: memcached:1 + ports: + - 11211:11211 + +