-
-
Notifications
You must be signed in to change notification settings - Fork 448
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
5348f88
commit 773a454
Showing
2 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,36 @@ | ||
package api | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
|
||
"github.com/pdfcpu/pdfcpu/pkg/pdfcpu/model" | ||
) | ||
|
||
func Test(t *testing.M) { | ||
t.Run() | ||
} | ||
|
||
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") | ||
} |