test(func): add tests for "issue edit"
This commit is contained in:
parent
9251487e56
commit
5bdd76d5dc
1 changed files with 178 additions and 0 deletions
|
|
@ -302,6 +302,184 @@ func TestCLIIssueClose(t *testing.T) {
|
||||||
t.Logf("Successfully tested issue close via API for CLI #%d", issueNum)
|
t.Logf("Successfully tested issue close via API for CLI #%d", issueNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestEditIssueTitle verifies we can edit an issue's title
|
||||||
|
func TestEditIssueTitle(t *testing.T) {
|
||||||
|
env := NewTestEnv(t)
|
||||||
|
|
||||||
|
// Create a test issue
|
||||||
|
issueNum := env.CreateTestIssue(
|
||||||
|
"[FGJ E2E Test] Original Title",
|
||||||
|
"This issue's title will be edited",
|
||||||
|
)
|
||||||
|
|
||||||
|
defer env.CleanupIssue(issueNum)
|
||||||
|
|
||||||
|
// Edit the title
|
||||||
|
newTitle := "[FGJ E2E Test] Updated Title"
|
||||||
|
_, _, err := env.Client.EditIssue(env.Owner, env.RepoName, issueNum, gitea.EditIssueOption{
|
||||||
|
Title: newTitle,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to edit issue title: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the title was updated
|
||||||
|
issue, _, err := env.Client.GetIssue(env.Owner, env.RepoName, issueNum)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to get issue: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.Title != newTitle {
|
||||||
|
t.Fatalf("expected title '%s', got '%s'", newTitle, issue.Title)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("Successfully edited issue #%d title", issueNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestEditIssueBody verifies we can edit an issue's body
|
||||||
|
func TestEditIssueBody(t *testing.T) {
|
||||||
|
env := NewTestEnv(t)
|
||||||
|
|
||||||
|
// Create a test issue
|
||||||
|
issueNum := env.CreateTestIssue(
|
||||||
|
"[FGJ E2E Test] Edit Body Test",
|
||||||
|
"Original body content",
|
||||||
|
)
|
||||||
|
|
||||||
|
defer env.CleanupIssue(issueNum)
|
||||||
|
|
||||||
|
// Edit the body
|
||||||
|
newBody := "Updated body content from functional test"
|
||||||
|
_, _, err := env.Client.EditIssue(env.Owner, env.RepoName, issueNum, gitea.EditIssueOption{
|
||||||
|
Body: &newBody,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to edit issue body: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the body was updated
|
||||||
|
issue, _, err := env.Client.GetIssue(env.Owner, env.RepoName, issueNum)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to get issue: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.Body != newBody {
|
||||||
|
t.Fatalf("expected body '%s', got '%s'", newBody, issue.Body)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("Successfully edited issue #%d body", issueNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestEditIssueState verifies we can edit an issue's state
|
||||||
|
func TestEditIssueState(t *testing.T) {
|
||||||
|
env := NewTestEnv(t)
|
||||||
|
|
||||||
|
// Create a test issue (starts as open)
|
||||||
|
issueNum := env.CreateTestIssue(
|
||||||
|
"[FGJ E2E Test] Edit State Test",
|
||||||
|
"This issue's state will be changed",
|
||||||
|
)
|
||||||
|
|
||||||
|
defer env.CleanupIssue(issueNum)
|
||||||
|
|
||||||
|
// Verify it starts as open
|
||||||
|
issue, _, err := env.Client.GetIssue(env.Owner, env.RepoName, issueNum)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to get issue: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.State != "open" {
|
||||||
|
t.Fatalf("expected initial state 'open', got '%s'", issue.State)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit state to closed
|
||||||
|
closedState := gitea.StateClosed
|
||||||
|
_, _, err = env.Client.EditIssue(env.Owner, env.RepoName, issueNum, gitea.EditIssueOption{
|
||||||
|
State: &closedState,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to edit issue state: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify state changed to 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 state 'closed' after edit, got '%s'", issue.State)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit state back to open
|
||||||
|
openState := gitea.StateOpen
|
||||||
|
_, _, err = env.Client.EditIssue(env.Owner, env.RepoName, issueNum, gitea.EditIssueOption{
|
||||||
|
State: &openState,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to reopen issue: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify state is now open
|
||||||
|
issue, _, err = env.Client.GetIssue(env.Owner, env.RepoName, issueNum)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to get issue: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.State != "open" {
|
||||||
|
t.Fatalf("expected state 'open' after reopen, got '%s'", issue.State)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("Successfully edited issue #%d state", issueNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestEditIssueMultipleFields verifies we can edit multiple issue fields at once
|
||||||
|
func TestEditIssueMultipleFields(t *testing.T) {
|
||||||
|
env := NewTestEnv(t)
|
||||||
|
|
||||||
|
// Create a test issue
|
||||||
|
issueNum := env.CreateTestIssue(
|
||||||
|
"[FGJ E2E Test] Original Multi-Edit",
|
||||||
|
"Original body for multi-field edit",
|
||||||
|
)
|
||||||
|
|
||||||
|
defer env.CleanupIssue(issueNum)
|
||||||
|
|
||||||
|
// Edit title, body, and state at once
|
||||||
|
newTitle := "[FGJ E2E Test] Updated Multi-Edit"
|
||||||
|
newBody := "Updated body from multi-field edit test"
|
||||||
|
closedState := gitea.StateClosed
|
||||||
|
|
||||||
|
_, _, err := env.Client.EditIssue(env.Owner, env.RepoName, issueNum, gitea.EditIssueOption{
|
||||||
|
Title: newTitle,
|
||||||
|
Body: &newBody,
|
||||||
|
State: &closedState,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to edit multiple issue fields: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify all fields were updated
|
||||||
|
issue, _, err := env.Client.GetIssue(env.Owner, env.RepoName, issueNum)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to get issue: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.Title != newTitle {
|
||||||
|
t.Fatalf("expected title '%s', got '%s'", newTitle, issue.Title)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.Body != newBody {
|
||||||
|
t.Fatalf("expected body '%s', got '%s'", newBody, issue.Body)
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.State != "closed" {
|
||||||
|
t.Fatalf("expected state 'closed', got '%s'", issue.State)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("Successfully edited multiple fields on issue #%d", issueNum)
|
||||||
|
}
|
||||||
|
|
||||||
// TestCLIPRList verifies the `fgj pr list` command works
|
// TestCLIPRList verifies the `fgj pr list` command works
|
||||||
func TestCLIPRList(t *testing.T) {
|
func TestCLIPRList(t *testing.T) {
|
||||||
env := NewTestEnv(t)
|
env := NewTestEnv(t)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue