MCPcopy Create free account
hub / github.com/appleboy/CodeGPT / TestAssignProcessToJob_InvalidPID

Function TestAssignProcessToJob_InvalidPID

util/api_key_helper_windows_test.go:49–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestAssignProcessToJob_InvalidPID(t *testing.T) {
50 job, err := createKillOnCloseJob()
51 if err != nil {
52 t.Fatalf("createKillOnCloseJob() error = %v", err)
53 }
54 defer func() {
55 _ = windows.CloseHandle(job)
56 }()
57
58 tests := []struct {
59 name string
60 pid int
61 }{
62 {
63 name: "negative PID",
64 pid: -1,
65 },
66 {
67 name: "PID exceeds max",
68 pid: 0x80000000,
69 },
70 }
71
72 for _, tt := range tests {
73 t.Run(tt.name, func(t *testing.T) {
74 _, err := assignProcessToJob(job, tt.pid)
75 if err == nil {
76 t.Error("assignProcessToJob() should return error for invalid PID")
77 }
78 if !strings.Contains(err.Error(), "invalid process ID") {
79 t.Errorf("error should mention invalid PID, got: %v", err)
80 }
81 })
82 }
83}
84
85func TestAssignProcessToJob_NonExistentPID(t *testing.T) {
86 job, err := createKillOnCloseJob()

Callers

nothing calls this directly

Calls 2

createKillOnCloseJobFunction · 0.85
assignProcessToJobFunction · 0.85

Tested by

no test coverage detected