mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
fix: migrate from github.com/rs/zerolog to golang-native log/slog (#3405)
* fix: migrate from github.com/rs/zerolog to golang-native log/slog We have been using zerolog for a really long time. golang now has structured logging using slog. Best to move to this in interests of long-term support. This is a tech debt item. Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com> * fix: a few changes on top Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com> * fix: address comments Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com> --------- Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d5779cfec8
commit
b1842ab9e0
+4
-1
@@ -1,6 +1,7 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -8,6 +9,7 @@ import (
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"go.etcd.io/bbolt"
|
||||
|
||||
"zotregistry.dev/zot/pkg/log"
|
||||
"zotregistry.dev/zot/pkg/storage/constants"
|
||||
)
|
||||
|
||||
@@ -19,7 +21,8 @@ func TestBoltDriverErrors(t *testing.T) {
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
driver := BoltDBDriver{
|
||||
db: boltDB,
|
||||
db: boltDB,
|
||||
log: log.NewLoggerWithWriter("debug", io.Discard),
|
||||
}
|
||||
|
||||
Convey("Empty boltdb", func() {
|
||||
|
||||
Vendored
+2
-2
@@ -16,7 +16,7 @@ func TestBoltDBCache(t *testing.T) {
|
||||
Convey("Make a new cache", t, func() {
|
||||
dir := t.TempDir()
|
||||
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
So(log, ShouldNotBeNil)
|
||||
|
||||
_, err := storage.Create("boltdb", "failTypeAssertion", log)
|
||||
@@ -126,7 +126,7 @@ func TestBoltDBCache(t *testing.T) {
|
||||
Convey("Test cache.GetAllBlos()", t, func() {
|
||||
dir := t.TempDir()
|
||||
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
So(log, ShouldNotBeNil)
|
||||
|
||||
_, err := storage.Create("boltdb", "failTypeAssertion", log)
|
||||
|
||||
Vendored
+3
-3
@@ -17,7 +17,7 @@ import (
|
||||
func TestDynamoDB(t *testing.T) {
|
||||
tskip.SkipDynamo(t)
|
||||
Convey("Test dynamoDB", t, func(c C) {
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
dir := t.TempDir()
|
||||
|
||||
// bad params
|
||||
@@ -146,7 +146,7 @@ func TestDynamoDB(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Test dynamoDB", t, func(c C) {
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
|
||||
cacheDriver, err := storage.Create("dynamodb", cache.DynamoDBDriverParameters{
|
||||
Endpoint: os.Getenv("DYNAMODBMOCK_ENDPOINT"),
|
||||
@@ -191,7 +191,7 @@ func TestDynamoDB(t *testing.T) {
|
||||
func TestDynamoDBError(t *testing.T) {
|
||||
tskip.SkipDynamo(t)
|
||||
Convey("Test dynamoDB", t, func(c C) {
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
|
||||
cacheDriver, err := cache.NewDynamoDBCache(cache.DynamoDBDriverParameters{
|
||||
Endpoint: os.Getenv("DYNAMODBMOCK_ENDPOINT"),
|
||||
|
||||
Vendored
+5
-5
@@ -28,7 +28,7 @@ func TestRedisCache(t *testing.T) {
|
||||
Convey("Make a new cache", t, func() {
|
||||
dir := t.TempDir()
|
||||
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
So(log, ShouldNotBeNil)
|
||||
|
||||
cacheDriver, err := storage.Create("redis", "failTypeAssertion", log)
|
||||
@@ -149,7 +149,7 @@ func TestRedisCache(t *testing.T) {
|
||||
Convey("Test cache.GetAllBlos()", t, func() {
|
||||
dir := t.TempDir()
|
||||
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
So(log, ShouldNotBeNil)
|
||||
|
||||
connOpts, _ := redis.ParseURL("redis://" + miniRedis.Addr())
|
||||
@@ -207,7 +207,7 @@ func TestRedisCacheError(t *testing.T) {
|
||||
connOpts, _ := redis.ParseURL(redisURL)
|
||||
brokenClient := redis.NewClient(connOpts)
|
||||
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
So(log, ShouldNotBeNil)
|
||||
|
||||
// redis server is not running
|
||||
@@ -221,7 +221,7 @@ func TestRedisCacheError(t *testing.T) {
|
||||
miniRedis := miniredis.RunT(t)
|
||||
dir := t.TempDir()
|
||||
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
So(log, ShouldNotBeNil)
|
||||
|
||||
connOpts, _ := redis.ParseURL("redis://" + miniRedis.Addr())
|
||||
@@ -260,7 +260,7 @@ func TestRedisMocked(t *testing.T) {
|
||||
Convey("Redis tests using mocks", t, func() {
|
||||
dir := t.TempDir()
|
||||
|
||||
log := log.NewLogger("debug", "")
|
||||
log := log.NewTestLogger()
|
||||
So(log, ShouldNotBeNil)
|
||||
|
||||
tests := []cache.RedisDriverParameters{
|
||||
|
||||
Reference in New Issue
Block a user