Fix bd-179: Derive prefix from database filename when config missing
- Add dbPath field to SQLiteStorage to track database file path - Create derivePrefixFromPath() helper to extract prefix from filename - Update ID generation in CreateIssue() and generateBatchIDs() to use filename fallback - Fix tests to explicitly set issue_prefix config for bd- prefixed tests When config doesn't have issue_prefix set, bd now correctly derives it from the database filename (e.g., wy-.db -> wy) instead of always defaulting to 'bd'. Fixes: bd-179
This commit is contained in:
@@ -30,6 +30,11 @@ func TestLazyCounterInitialization(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Set the issue prefix to "bd" for this test
|
||||
if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil {
|
||||
t.Fatalf("Failed to set issue_prefix: %v", err)
|
||||
}
|
||||
|
||||
// Create some issues with explicit IDs (simulating import)
|
||||
existingIssues := []string{"bd-5", "bd-10", "bd-15"}
|
||||
for _, id := range existingIssues {
|
||||
@@ -182,6 +187,11 @@ func TestCounterInitializationFromExisting(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Set the issue prefix to "bd" for this test
|
||||
if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil {
|
||||
t.Fatalf("Failed to set issue_prefix: %v", err)
|
||||
}
|
||||
|
||||
// Create issues with explicit IDs, out of order
|
||||
explicitIDs := []string{"bd-5", "bd-100", "bd-42", "bd-7"}
|
||||
for _, id := range explicitIDs {
|
||||
|
||||
Reference in New Issue
Block a user