Improve test coverage for bd-136
Added tests for internal/rpc and internal/storage/sqlite: RPC tests (+5.8% coverage: 58.0% → 63.8%): - TestCloseIssue: Cover handleClose (was 0%) - TestReposStats: Cover handleReposStats (was 0%) - TestReposClearCache: Cover handleReposClearCache (was 0%) - TestEpicStatus: Cover handleEpicStatus (was 0%) Storage tests (+2.6% coverage: 62.2% → 64.8%): - Created epics_test.go with TestGetEpicsEligibleForClosure - TestUpdateIssueValidation: validateIssueType, validateEstimatedMinutes - TestGetAllConfig, TestDeleteConfig, TestIsClosed Overall coverage: 48.7% → 50.7% (+2.0%) Progress on bd-136: Achieve 75% test coverage across codebase Amp-Thread-ID: https://ampcode.com/threads/T-16b56923-6fbc-45db-b68b-315567849ec6 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -223,6 +223,54 @@ func TestUpdateIssue(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloseIssue(t *testing.T) {
|
||||
_, client, cleanup := setupTestServer(t)
|
||||
defer cleanup()
|
||||
|
||||
createArgs := &CreateArgs{
|
||||
Title: "Issue to Close",
|
||||
IssueType: "task",
|
||||
Priority: 2,
|
||||
}
|
||||
|
||||
createResp, err := client.Create(createArgs)
|
||||
if err != nil {
|
||||
t.Fatalf("Create failed: %v", err)
|
||||
}
|
||||
|
||||
var issue types.Issue
|
||||
json.Unmarshal(createResp.Data, &issue)
|
||||
|
||||
if issue.Status != "open" {
|
||||
t.Errorf("Expected status 'open', got %s", issue.Status)
|
||||
}
|
||||
|
||||
closeArgs := &CloseArgs{
|
||||
ID: issue.ID,
|
||||
Reason: "Test completion",
|
||||
}
|
||||
|
||||
closeResp, err := client.CloseIssue(closeArgs)
|
||||
if err != nil {
|
||||
t.Fatalf("CloseIssue failed: %v", err)
|
||||
}
|
||||
|
||||
if !closeResp.Success {
|
||||
t.Fatalf("Expected success, got error: %s", closeResp.Error)
|
||||
}
|
||||
|
||||
var closedIssue types.Issue
|
||||
json.Unmarshal(closeResp.Data, &closedIssue)
|
||||
|
||||
if closedIssue.Status != "closed" {
|
||||
t.Errorf("Expected status 'closed', got %s", closedIssue.Status)
|
||||
}
|
||||
|
||||
if closedIssue.ClosedAt == nil {
|
||||
t.Error("Expected ClosedAt to be set, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestListIssues(t *testing.T) {
|
||||
_, client, cleanup := setupTestServer(t)
|
||||
defer cleanup()
|
||||
|
||||
Reference in New Issue
Block a user