Repository: cli/cli
File: pkg/cmd/agent-task/create/create_test.go (Go)

Code before:
				case isStdin:
					stdinBuf.WriteString(tt.fileContent)
				case hasFileToken:
					dir := t.TempDir()
					path := filepath.Join(dir, "task.md")
					if err := os.WriteFile(path, []byte(tt.fileContent), 0o600); err != nil {
						t.Fatalf("failed to write temp file: %v", err)
					}
					for i, a := range tt.args {
						if a == "{{FILE}}" {
							tt.args[i] = path
						}
					}
				}
			}

			f := &cmdutil.Factory{IOStreams: ios}
			var gotOpts *CreateOptions
			cmd := NewCmdCreate(f, func(o *CreateOptions) error {
				gotOpts = o
				return nil
			})
			cmd.SetArgs(tt.args)
			_, err := cmd.ExecuteC()

			if tt.expectedErr != "" {
				require.Error(t, err)
				require.Equal(t, tt.expectedErr, err.Error())
				return
			}
			require.NoError(t, err)
			if tt.wantOpts != nil {
				require.Equal(t, tt.wantOpts.ProblemStatement, gotOpts.ProblemStatement)
			}
		})
	}
}

func Test_createRun(t *testing.T) {
	createdJobSuccessResponse := heredoc.Doc(`{
		"job_id":"job123",
		"session_id":"sess1",
		"actor":{"id":1,"login":"octocat"},
		"created_at":"2025-08-29T00:00:00Z",
		"updated_at":"2025-08-29T00:00:00Z"
	}`)
	createdJobSuccessWithPRResponse := heredoc.Doc(`{
		"job_id":"job123",
		"session_id":"sess1",
		"actor":{"id":1,"login":"octocat"},
		"created_at":"2025-08-29T00:00:00Z",

Review comment (bug):
The error message is different on Windows. That's why the CI is failing.

```
expected: "could not read task description file: open does-not-exist.md: no such file or directory"
actual  : "could not read task description file: open does-not-exist.md: The system cannot find the file specified."
```

I think we can just switch to `require.ErrorContains` like below and remove the OS message part from the test case's `expectedErr`. What do you think?


```suggestion
				require.ErrorContains(t, err, tt.expectedErr)
```

Code after:
				case hasFileToken:
					dir := t.TempDir()
					path := filepath.Join(dir, "task.md")
					if err := os.WriteFile(path, []byte(tt.fileContent), 0o600); err != nil {
						t.Fatalf("failed to write temp file: %v", err)
					}
					for i, a := range tt.args {
						if a == "{{FILE}}" {
							tt.args[i] = path
						}
					}
				}
			}

			f := &cmdutil.Factory{IOStreams: ios}
			var gotOpts *CreateOptions
			cmd := NewCmdCreate(f, func(o *CreateOptions) error {
				gotOpts = o
				return nil
			})
			cmd.SetArgs(tt.args)
			_, err := cmd.ExecuteC()

			if tt.expectedErr != "" {
				require.Error(t, err)
				require.Equal(t, tt.expectedErr, err.Error())
				return
			}
			require.NoError(t, err)
			if tt.wantOpts != nil {
				require.Equal(t, tt.wantOpts.ProblemStatement, gotOpts.ProblemStatement)
			}
		})
	}
}

func Test_createRun(t *testing.T) {
	createdJobSuccessResponse := heredoc.Doc(`{
		"job_id":"job123",
		"session_id":"sess1",
		"actor":{"id":1,"login":"octocat"},
		"created_at":"2025-08-29T00:00:00Z",
		"updated_at":"2025-08-29T00:00:00Z"
	}`)
	createdJobSuccessWithPRResponse := heredoc.Doc(`{
		"job_id":"job123",
		"session_id":"sess1",
		"actor":{"id":1,"login":"octocat"},
		"created_at":"2025-08-29T00:00:00Z",
		"updated_at":"2025-08-29T00:00:00Z",
		"pull_request":{"id":101,"number":42}