feat: allow passing a comment when closing an issue

This commit is contained in:
Romain Bertrand 2026-01-16 10:03:49 +01:00
parent fc699e9718
commit 900bd4ea97
3 changed files with 74 additions and 0 deletions

View file

@ -304,6 +304,66 @@ func TestCLIIssueClose(t *testing.T) {
t.Logf("Successfully tested issue close via API for CLI #%d", issueNum)
}
// TestCLIIssueCloseWithComment verifies the `fgj issue close -c` command works
func TestCLIIssueCloseWithComment(t *testing.T) {
env := NewTestEnv(t)
// Create an issue via API
issueNum := env.CreateTestIssue(
"[FGJ CLI Test] Close with comment",
"This issue will be closed with a comment in one command",
)
commentText := "Fixed in v2.0 - closing via functional test"
// Close with comment via CLI
result := env.RunCLI(
"--hostname", env.Hostname,
"issue", "close",
fmt.Sprintf("%d", issueNum),
"-c", commentText,
)
if result.ExitCode != 0 {
t.Fatalf("issue close -c failed with exit code %d: %s", result.ExitCode, result.Stderr)
}
// Verify the issue was closed
issue, _, err := env.Client.GetIssue(env.Owner, env.RepoName, issueNum)
if err != nil {
t.Fatalf("failed to get issue: %v", err)
}
if issue.State != "closed" {
t.Fatalf("expected issue state 'closed', got '%s'", issue.State)
}
// Verify the comment was added
comments, _, err := env.Client.ListIssueComments(env.Owner, env.RepoName, issueNum, gitea.ListIssueCommentOptions{})
if err != nil {
t.Fatalf("failed to list issue comments: %v", err)
}
if len(comments) == 0 {
t.Fatalf("expected at least one comment, got none")
}
// Find our comment
found := false
for _, comment := range comments {
if comment.Body == commentText {
found = true
break
}
}
if !found {
t.Fatalf("comment '%s' not found in issue comments", commentText)
}
t.Logf("Successfully tested issue close with comment via CLI #%d", issueNum)
}
// TestEditIssueTitle verifies we can edit an issue's title
func TestEditIssueTitle(t *testing.T) {
env := NewTestEnv(t)