(t *testing.T)
| 126 | } |
| 127 | |
| 128 | func Test_createRun(t *testing.T) { |
| 129 | tmpDir := t.TempDir() |
| 130 | taskDescFile := filepath.Join(tmpDir, "task-description.md") |
| 131 | emptyTaskDescFile := filepath.Join(tmpDir, "empty-task-description.md") |
| 132 | require.NoError(t, os.WriteFile(taskDescFile, []byte("task description from file"), 0600)) |
| 133 | require.NoError(t, os.WriteFile(emptyTaskDescFile, []byte(" \n\n"), 0600)) |
| 134 | |
| 135 | sampleDateString := "2025-08-29T00:00:00Z" |
| 136 | sampleDate, err := time.Parse(time.RFC3339, sampleDateString) |
| 137 | require.NoError(t, err) |
| 138 | |
| 139 | createdJobSuccess := capi.Job{ |
| 140 | ID: "job123", |
| 141 | SessionID: "sess1", |
| 142 | Actor: &capi.JobActor{ |
| 143 | ID: 1, |
| 144 | Login: "octocat", |
| 145 | }, |
| 146 | CreatedAt: sampleDate, |
| 147 | UpdatedAt: sampleDate, |
| 148 | } |
| 149 | createdJobSuccessWithPR := capi.Job{ |
| 150 | ID: "job123", |
| 151 | SessionID: "sess1", |
| 152 | Actor: &capi.JobActor{ |
| 153 | ID: 1, |
| 154 | Login: "octocat", |
| 155 | }, |
| 156 | CreatedAt: sampleDate, |
| 157 | UpdatedAt: sampleDate, |
| 158 | PullRequest: &capi.JobPullRequest{ |
| 159 | ID: 101, |
| 160 | Number: 42, |
| 161 | }, |
| 162 | } |
| 163 | |
| 164 | tests := []struct { |
| 165 | name string |
| 166 | isTTY bool |
| 167 | opts *CreateOptions // input options (IO & BackOff set later) |
| 168 | capiStubs func(*testing.T, *capi.CapiClientMock) |
| 169 | logRendererStubs func(*testing.T, *shared.LogRendererMock) |
| 170 | wantStdout string |
| 171 | wantStdErr string |
| 172 | wantErr string |
| 173 | wantErrIs error |
| 174 | }{ |
| 175 | { |
| 176 | name: "interactive, problem statement from arg", |
| 177 | isTTY: true, |
| 178 | opts: &CreateOptions{ |
| 179 | BaseRepo: func() (ghrepo.Interface, error) { return ghrepo.New("OWNER", "REPO"), nil }, |
| 180 | ProblemStatement: "task description from arg", |
| 181 | }, |
| 182 | capiStubs: func(t *testing.T, m *capi.CapiClientMock) { |
| 183 | m.CreateJobFunc = func(ctx context.Context, owner, repo, problemStatement, baseBranch, customAgent string) (*capi.Job, error) { |
| 184 | require.Equal(t, "OWNER", owner) |
| 185 | require.Equal(t, "REPO", repo) |
nothing calls this directly
no test coverage detected