Complete bd-175, bd-176, bd-177: Memory tests, corruption docs, prefix validation
- bd-175: Added comprehensive test coverage for internal/storage/memory backend - All CRUD operations, dependencies, labels, comments - Thread safety with race detection - LoadFromIssues and counter sync - Fixed batch duplicate detection - bd-176: Documented corruption vs collision distinction - Added FAQ entry explaining logical vs physical corruption - Updated TROUBLESHOOTING with clear guidance - Clarified when to use collision resolution vs reimport - bd-177: Added prefix validation in SQLite mode - Validates explicit IDs match configured prefix - Works in both CreateIssue and CreateIssues - Comprehensive tests for single and batch operations
This commit is contained in:
@@ -209,6 +209,9 @@ func (m *MemoryStorage) CreateIssues(ctx context.Context, issues []*types.Issue,
|
||||
prefix = "bd"
|
||||
}
|
||||
|
||||
// Track IDs in this batch to detect duplicates within batch
|
||||
batchIDs := make(map[string]bool)
|
||||
|
||||
// Generate IDs for issues that need them
|
||||
for _, issue := range issues {
|
||||
issue.CreatedAt = now
|
||||
@@ -219,10 +222,16 @@ func (m *MemoryStorage) CreateIssues(ctx context.Context, issues []*types.Issue,
|
||||
issue.ID = fmt.Sprintf("%s-%d", prefix, m.counters[prefix])
|
||||
}
|
||||
|
||||
// Check for duplicates
|
||||
// Check for duplicates in existing issues
|
||||
if _, exists := m.issues[issue.ID]; exists {
|
||||
return fmt.Errorf("issue %s already exists", issue.ID)
|
||||
}
|
||||
|
||||
// Check for duplicates within this batch
|
||||
if batchIDs[issue.ID] {
|
||||
return fmt.Errorf("duplicate ID within batch: %s", issue.ID)
|
||||
}
|
||||
batchIDs[issue.ID] = true
|
||||
}
|
||||
|
||||
// Store all issues
|
||||
|
||||
Reference in New Issue
Block a user