(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func 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 | |
| 85 | func TestAssignProcessToJob_NonExistentPID(t *testing.T) { |
| 86 | job, err := createKillOnCloseJob() |
nothing calls this directly
no test coverage detected