Add comprehensive unit tests for CreateIssues (bd-241)
- Added 12 table-driven test cases covering all validation scenarios - Added 2 rollback tests (validation error + DB conflict) - Added nil item detection to prevent panic - Fixed nil pointer panic in CreateIssues - Tests verify ID uniqueness, timestamps, closed_at invariant - All tests pass Amp-Thread-ID: https://ampcode.com/threads/T-61c584cd-d873-4a1a-bfa6-d739b630b3e5 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -518,9 +518,13 @@ func (s *SQLiteStorage) CreateIssues(ctx context.Context, issues []*types.Issue,
|
||||
return nil
|
||||
}
|
||||
|
||||
// Phase 1: Set timestamps and validate all issues first (fail-fast)
|
||||
// Phase 1: Check for nil and validate all issues first (fail-fast)
|
||||
now := time.Now()
|
||||
for i, issue := range issues {
|
||||
if issue == nil {
|
||||
return fmt.Errorf("issue %d is nil", i)
|
||||
}
|
||||
|
||||
issue.CreatedAt = now
|
||||
issue.UpdatedAt = now
|
||||
|
||||
|
||||
Reference in New Issue
Block a user