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:
@@ -188,6 +188,13 @@ func TestMigrateIssueCountersTableEmptyDB(t *testing.T) {
|
||||
|
||||
// Create first issue - should work fine
|
||||
ctx := context.Background()
|
||||
|
||||
// Set the issue prefix to "bd" for this test
|
||||
err = store.SetConfig(ctx, "issue_prefix", "bd")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to set issue_prefix: %v", err)
|
||||
}
|
||||
|
||||
issue := &types.Issue{
|
||||
Title: "First issue",
|
||||
Status: types.StatusOpen,
|
||||
@@ -225,6 +232,13 @@ func TestMigrateIssueCountersTableIdempotent(t *testing.T) {
|
||||
|
||||
// Create some issues
|
||||
ctx := context.Background()
|
||||
|
||||
// Set the issue prefix to "bd" for this test
|
||||
err = store1.SetConfig(ctx, "issue_prefix", "bd")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to set issue_prefix: %v", err)
|
||||
}
|
||||
|
||||
issue := &types.Issue{
|
||||
Title: "Test issue",
|
||||
Status: types.StatusOpen,
|
||||
|
||||
Reference in New Issue
Block a user