返回 DeepSeek-Reasonix
pinned_files_fifo_unix_test.go
根目录 / desktop / pinned_files_fifo_unix_test.go
1 //go:build !windows && !plan9
2
3 package main
4
5 import (
6 "errors"
7 "path/filepath"
8 "syscall"
9 "testing"
10 "time"
11 )
12
13 func TestReadPinnedWorkspaceFileRejectsFIFOWithoutBlocking(t *testing.T) {
14 root := t.TempDir()
15 path := filepath.Join(root, "context.fifo")
16 if err := syscall.Mkfifo(path, 0o600); err != nil {
17 t.Fatal(err)
18 }
19 done := make(chan error, 1)
20 go func() {
21 _, _, _, err := readPinnedWorkspaceFile(root, "context.fifo")
22 done <- err
23 }()
24 select {
25 case err := <-done:
26 if !errors.Is(err, errPinnedNotRegular) {
27 t.Fatalf("readPinnedWorkspaceFile() error = %v, want errPinnedNotRegular", err)
28 }
29 case <-time.After(2 * time.Second):
30 t.Fatal("readPinnedWorkspaceFile blocked while opening a FIFO")
31 }
32 }
33
33 lines GO