MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestOpenDBConcurrentDoesNotBusy

Function TestOpenDBConcurrentDoesNotBusy

internal/flowdb/db_test.go:71–94  ·  view source on GitHub ↗

TestOpenDBConcurrentDoesNotBusy pins that two parallel OpenDB calls on the same path don't race during schema setup. Without busy_timeout applied at open time, the loser hits SQLITE_BUSY on `pragma table_info(tasks)` during runMigrations on slow runners — observed as a flaky CI failure on the app-le

(t *testing.T)

Source from the content-addressed store, hash-verified

69// table_info(tasks)` during runMigrations on slow runners — observed
70// as a flaky CI failure on the app-level concurrent-do test.
71func TestOpenDBConcurrentDoesNotBusy(t *testing.T) {
72 path := filepath.Join(t.TempDir(), "flow.db")
73 const n = 8
74 var wg sync.WaitGroup
75 errs := make([]error, n)
76 wg.Add(n)
77 for i := range n {
78 go func() {
79 defer wg.Done()
80 db, err := OpenDB(path)
81 if err != nil {
82 errs[i] = err
83 return
84 }
85 db.Close()
86 }()
87 }
88 wg.Wait()
89 for i, err := range errs {
90 if err != nil {
91 t.Errorf("goroutine %d: %v", i, err)
92 }
93 }
94}
95
96func TestProjectCRUD(t *testing.T) {
97 db := openTempDB(t)

Callers

nothing calls this directly

Calls 1

OpenDBFunction · 0.85

Tested by

no test coverage detected