aboutsummaryrefslogtreecommitdiffhomepage
path: root/replacer_test.go
diff options
context:
space:
mode:
authorMohammed Al Sahaf <[email protected]>2024-03-21 21:15:18 +0300
committerGitHub <[email protected]>2024-03-21 18:15:18 +0000
commite7336cc3bfcf60eb775c60509d521e92a5a3b6fe (patch)
tree13bab6446abffe65401ef476a63fa6681226416e /replacer_test.go
parent97a56d860a2254f4d9939746a33698b365d546d6 (diff)
downloadcaddy-e7336cc3bfcf60eb775c60509d521e92a5a3b6fe.tar.gz
caddy-e7336cc3bfcf60eb775c60509d521e92a5a3b6fe.zip
replacer: use RWMutex to protect static provider (#6184)
Diffstat (limited to 'replacer_test.go')
-rw-r--r--replacer_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/replacer_test.go b/replacer_test.go
index c88683947..d18ec8eea 100644
--- a/replacer_test.go
+++ b/replacer_test.go
@@ -19,6 +19,7 @@ import (
"os"
"path/filepath"
"runtime"
+ "sync"
"testing"
)
@@ -238,6 +239,7 @@ func TestReplacerSet(t *testing.T) {
func TestReplacerReplaceKnown(t *testing.T) {
rep := Replacer{
+ mapMutex: &sync.RWMutex{},
providers: []ReplacerFunc{
// split our possible vars to two functions (to test if both functions are called)
func(key string) (val any, ok bool) {
@@ -310,6 +312,7 @@ func TestReplacerReplaceKnown(t *testing.T) {
func TestReplacerDelete(t *testing.T) {
rep := Replacer{
+ mapMutex: &sync.RWMutex{},
static: map[string]any{
"key1": "val1",
"key2": "val2",
@@ -463,5 +466,6 @@ func testReplacer() Replacer {
return Replacer{
providers: make([]ReplacerFunc, 0),
static: make(map[string]any),
+ mapMutex: &sync.RWMutex{},
}
}