Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): Protects DisableConfigDir from concurrent access using mutex
- Loading branch information
1 parent
fff3853
commit 7c02e0d
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package api | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
|
||
"github.com/pdfcpu/pdfcpu/pkg/pdfcpu/model" | ||
) | ||
|
||
func TestDisableConfigDir(t *testing.T) { | ||
t.Parallel() | ||
DisableConfigDir() | ||
|
||
if model.ConfigPath != "disable" { | ||
t.Errorf("model.ConfigPath != \"disable\" (%s)", model.ConfigPath) | ||
} | ||
} | ||
|
||
func TestDisableConfigDir_Parallel(t *testing.T) { | ||
t.Parallel() | ||
|
||
var wg sync.WaitGroup | ||
for i := 0; i < 100; i++ { | ||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
DisableConfigDir() | ||
}() | ||
} | ||
wg.Wait() | ||
t.Log("DisableConfigDir is passed") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters