← back to Cli Printing Press
test(pipeline): add concurrency test for ClaimOutputDir
0fd4cba64faa4b8e5c44514a8ebce064a0f57de5 · 2026-03-27 19:37:33 -0700 · Trevin Chow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Files touched
M internal/pipeline/claim_test.go
Diff
commit 0fd4cba64faa4b8e5c44514a8ebce064a0f57de5
Author: Trevin Chow <trevin@trevinchow.com>
Date: Fri Mar 27 19:37:33 2026 -0700
test(pipeline): add concurrency test for ClaimOutputDir
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---
internal/pipeline/claim_test.go | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/internal/pipeline/claim_test.go b/internal/pipeline/claim_test.go
index c21a9d2f..26e87f53 100644
--- a/internal/pipeline/claim_test.go
+++ b/internal/pipeline/claim_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "sync"
"testing"
"github.com/stretchr/testify/assert"
@@ -65,3 +66,42 @@ func TestClaimOutputDir_PermissionError(t *testing.T) {
// Should NOT contain "could not claim" — should be the underlying OS error
assert.NotContains(t, err.Error(), "could not claim")
}
+
+func TestClaimOutputDir_ConcurrentClaims(t *testing.T) {
+ tmp := t.TempDir()
+ base := filepath.Join(tmp, "notion-pp-cli")
+
+ const goroutines = 20
+ var wg sync.WaitGroup
+ results := make(chan string, goroutines)
+ errs := make(chan error, goroutines)
+
+ wg.Add(goroutines)
+ for i := 0; i < goroutines; i++ {
+ go func() {
+ defer wg.Done()
+ claimed, err := ClaimOutputDir(base)
+ if err != nil {
+ errs <- err
+ return
+ }
+ results <- claimed
+ }()
+ }
+ wg.Wait()
+ close(results)
+ close(errs)
+
+ // No errors
+ for err := range errs {
+ t.Errorf("unexpected error: %v", err)
+ }
+
+ // All claimed paths must be unique
+ seen := map[string]bool{}
+ for path := range results {
+ assert.False(t, seen[path], "duplicate claim: %s", path)
+ seen[path] = true
+ }
+ assert.Len(t, seen, goroutines)
+}
← 93b8b4cc feat(pipeline): add ClaimOutputDir for atomic directory clai
·
back to Cli Printing Press
·
refactor(cli): use ClaimOutputDir for atomic output director da9500e4 →