Files
dingtalk-workspace-cli/internal/event/process/process_alive_unix_test.go
玉澜 0fbdfe0130 test(seam): make testseam the only seam-swap form and legislate it
- Add testseam.Protect for save-and-restore seams with no up-front stub
  value (e.g. os.Args mutated by the code under test).
- Migrate all 35 remaining manual prev/assign/t.Cleanup-restore trios to
  testseam.Swap/Protect across app, auth, cli, event, helpers, output,
  pipeline, and shortcut tests; restores can no longer be forgotten.
- check-schema-catalog.sh: fail closed when a manual seam restore
  reappears in any *_test.go (internal/testseam exempt).

Seam injection is now a mechanism, not a convention.
2026-08-03 20:00:47 +08:00

25 lines
599 B
Go

//go:build !windows
package process
import (
"errors"
"syscall"
"testing"
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/testseam"
)
func TestCrossPlatformCoverageAliveUnixErrorClassification(t *testing.T) {
testseam.Protect(t, &killProcess)
for _, tc := range []struct {
err error
want bool
}{{nil, true}, {syscall.EPERM, true}, {syscall.ESRCH, false}, {errors.New("ambiguous"), true}} {
killProcess = func(int, syscall.Signal) error { return tc.err }
if got := Alive(42); got != tc.want {
t.Errorf("Alive with %v = %v, want %v", tc.err, got, tc.want)
}
}
}