mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
35 lines
889 B
Go
35 lines
889 B
Go
// Copyright 2026 Hanzo AI Inc. All Rights Reserved.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
// Both surfaces share the file cache, so concurrent readers and writers are the
|
|
// ordinary case. This holds the map's guard honest: a Go map without one is a
|
|
// runtime fatal error under concurrency, which no recover() can answer for.
|
|
func TestTheFileCacheIsReachedFromBothDoorsAtOnce(t *testing.T) {
|
|
var wg sync.WaitGroup
|
|
for i := range 64 {
|
|
wg.Add(1)
|
|
go func(i int) {
|
|
defer wg.Done()
|
|
prefix := fmt.Sprintf("prefix-%d", i%8)
|
|
rememberPath(prefix, fmt.Sprintf("/cache/%d", i))
|
|
if _, ok := cachedPath(prefix); !ok {
|
|
t.Errorf("%s was remembered and then not found", prefix)
|
|
}
|
|
}(i)
|
|
}
|
|
wg.Wait()
|
|
|
|
for i := range 8 {
|
|
if _, ok := cachedPath(fmt.Sprintf("prefix-%d", i)); !ok {
|
|
t.Errorf("prefix-%d is missing after the writes settled", i)
|
|
}
|
|
}
|
|
}
|