fix(query): 保留业务异常并消除选项复用状态
Verify / verify (push) Canceled after 0s

This commit is contained in:
zhangdeman committed 2026-11-28 03:15:47 -08:00
1 parent d2a9033695
commit 734d389a7c
5 files changed
+91 -13

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
package query
import (
"sync"
"testing"
)
func TestOptionsCanBeReusedWithoutChangingOrderInput(t *testing.T) {
input := []string{"id", ""}
order, lock := WithOrder(input...), WithLockingStrength("update")
var (
wait sync.WaitGroup
)
for range 20 {
wait.Go(func() {
option := &Option{}
order(option)
lock(option)
if len(option.Order) != 2 || option.Order[1] != "DESC" || option.LockingStrength != "UPDATE" {
t.Error("option behavior changed")
}
option.Order[0] = "only-this-call"
})
}
wait.Wait()
if input[0] != "id" || input[1] != "" {
t.Fatalf("input mutated: %v", input)
}
option := &Option{}
order(option)
if option.Order[0] != "id" {
t.Fatal("option results share mutable slices")
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.