diff options
Diffstat (limited to 'modules/setting/global_lock_test.go')
-rw-r--r-- | modules/setting/global_lock_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/setting/global_lock_test.go b/modules/setting/global_lock_test.go new file mode 100644 index 0000000000..5eeb275523 --- /dev/null +++ b/modules/setting/global_lock_test.go @@ -0,0 +1,35 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package setting + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestLoadGlobalLockConfig(t *testing.T) { + t.Run("DefaultGlobalLockConfig", func(t *testing.T) { + iniStr := `` + cfg, err := NewConfigProviderFromData(iniStr) + assert.NoError(t, err) + + loadGlobalLockFrom(cfg) + assert.EqualValues(t, "memory", GlobalLock.ServiceType) + }) + + t.Run("RedisGlobalLockConfig", func(t *testing.T) { + iniStr := ` +[global_lock] +SERVICE_TYPE = redis +SERVICE_CONN_STR = addrs=127.0.0.1:6379 db=0 +` + cfg, err := NewConfigProviderFromData(iniStr) + assert.NoError(t, err) + + loadGlobalLockFrom(cfg) + assert.EqualValues(t, "redis", GlobalLock.ServiceType) + assert.EqualValues(t, "addrs=127.0.0.1:6379 db=0", GlobalLock.ServiceConnStr) + }) +} |