Skip to content

Commit

Permalink
constants:类型补全,utils:补充测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
keepchen committed Feb 12, 2025
1 parent f6bf318 commit dd8fbf7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion constants/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ const (
TimeLayout string = "15:04:05" //时间格式
DatetimeLayout string = "2006-01-02 15:04:05" //日期时间格式
DatetimeTZLayout string = "2006-01-02T15:04:05Z" //日期时间格式-tz
DateTimeTZLayoutWithMilli = "2006-01-02T15:04:05.000Z" //日期时间格式-tz,带毫秒
DateTimeTZLayoutWithMilli string = "2006-01-02T15:04:05.000Z" //日期时间格式-tz,带毫秒
)
6 changes: 3 additions & 3 deletions utils/redislock.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ func (rl redisLockerImpl) TryLock(key string) bool {
// # Note
//
// 该方法会立即返回锁定成功与否的结果
func (redisLockerImpl) TryLockWithContext(ctx context.Context, key string) bool {
func (rl redisLockerImpl) TryLockWithContext(ctx context.Context, key string) bool {
if redis.GetInstance() != nil {
return RedisStandaloneLockWithContext(ctx, key)
return rl.StandaloneLockWithContext(ctx, key)
}

if redis.GetClusterInstance() != nil {
return RedisClusterLockWithContext(ctx, key)
return rl.ClusterLockWithContext(ctx, key)
}

panic("using redis lock on nil redis instance")
Expand Down
22 changes: 22 additions & 0 deletions utils/version_deprecated_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package utils

import (
"runtime"
"testing"
"time"

"github.com/keepchen/go-sail/v3/constants"
)

func TestPrintVersion(t *testing.T) {
var fields = VersionInfoFieldsDeprecated{
AppName: "go-sail",
Version: constants.GoSailVersion,
Branch: "main",
Revision: "cf6e7f1",
BuildDate: Datetime().FormatDate(time.Now(), YYYY_MM_DD_HH_MM_SS_EN),
GoVersion: runtime.Version(),
}

PrintVersion(fields)
}
2 changes: 1 addition & 1 deletion utils/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/keepchen/go-sail/v3/constants"
)

func TestPrintVersion(t *testing.T) {
func TestVersionImplPrint(t *testing.T) {
var fields = VersionInfoFields{
AppName: "go-sail",
Version: constants.GoSailVersion,
Expand Down

0 comments on commit dd8fbf7

Please sign in to comment.