Files
aego/asset/pipeline/primary_artifact_test.go
sanspie 5eb1832907
ci-platforms / darwin amd64 smoke (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Failing after 15m28s
ci / release (push) Skipped
ci-platforms / windows amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci / checks (push) Successful in 7m47s
Complete Stage 12 for v0.12.0
2026-11-05 11:46:53 +03:00

43 lines
871 B
Go

package pipeline
import (
"aego/asset"
"aego/core/ids"
"sync"
"testing"
)
func TestPreviewAtlasArtifactDuringIndexRefresh(t *testing.T) {
p := &Pipeline{index: asset.NewIndex()}
id := ids.NewAssetID()
set := func(path string) {
p.index.Put(asset.Entry{ID: id, Kind: asset.ArtAtlasPage, Artifacts: []asset.Artifact{{Kind: asset.ArtAtlasPage, Path: path, Hash: path}}})
}
set("A")
start := make(chan struct{})
var workers sync.WaitGroup
workers.Add(1)
go func() {
defer workers.Done()
<-start
for i := 0; i < 3000; i++ {
p.mu.Lock()
if i%2 == 0 {
set("A")
} else {
set("B")
}
p.mu.Unlock()
}
}()
close(start)
for i := 0; i < 3000; i++ {
a, ok := p.PrimaryArtifact(id)
if !ok || (a.Path != "A" && a.Path != "B") || a.Hash != a.Path {
t.Errorf("inconsistent atlas artifact: %+v", a)
break
}
}
workers.Wait()
}