Add routing integration tests and documentation
- Created routing_integration_test.go with comprehensive routing tests - Tests cover maintainer/contributor detection, explicit overrides, end-to-end multi-repo - Added docs/ROUTING.md documenting auto-routing feature - Closed bd-6u6g, bd-zmi5, bd-nzt4, bd-btsm (routing tests) - Updated bd-4ms and bd-8hf with progress notes All routing tests pass. Multi-repo auto-routing is complete. Amp-Thread-ID: https://ampcode.com/threads/T-2ea8b2ed-ceb7-432e-91f1-1f527b0e7b4d Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -258,6 +258,42 @@ var createCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Check if any dependencies are discovered-from type
|
||||
// If so, inherit source_repo from the parent issue
|
||||
var discoveredFromParentID string
|
||||
for _, depSpec := range deps {
|
||||
depSpec = strings.TrimSpace(depSpec)
|
||||
if depSpec == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
var depType types.DependencyType
|
||||
var dependsOnID string
|
||||
|
||||
if strings.Contains(depSpec, ":") {
|
||||
parts := strings.SplitN(depSpec, ":", 2)
|
||||
if len(parts) == 2 {
|
||||
depType = types.DependencyType(strings.TrimSpace(parts[0]))
|
||||
dependsOnID = strings.TrimSpace(parts[1])
|
||||
|
||||
if depType == types.DepDiscoveredFrom {
|
||||
discoveredFromParentID = dependsOnID
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we found a discovered-from dependency, inherit source_repo from parent
|
||||
if discoveredFromParentID != "" {
|
||||
parentIssue, err := store.GetIssue(ctx, discoveredFromParentID)
|
||||
if err == nil && parentIssue.SourceRepo != "" {
|
||||
issue.SourceRepo = parentIssue.SourceRepo
|
||||
}
|
||||
// If error getting parent or parent has no source_repo, continue with default
|
||||
}
|
||||
|
||||
if err := store.CreateIssue(ctx, issue, actor); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -450,3 +450,74 @@ func TestCreate_MultipleDependencies(t *testing.T) {
|
||||
t.Fatalf("expected 2 dependencies, got %d", len(deps))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreate_DiscoveredFromInheritsSourceRepo(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
testDB := filepath.Join(tmpDir, ".beads", "beads.db")
|
||||
s := newTestStore(t, testDB)
|
||||
ctx := context.Background()
|
||||
|
||||
// Create a parent issue with a custom source_repo
|
||||
parent := &types.Issue{
|
||||
Title: "Parent issue",
|
||||
Priority: 1,
|
||||
Status: types.StatusOpen,
|
||||
IssueType: types.TypeTask,
|
||||
SourceRepo: "/path/to/custom/repo",
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
if err := s.CreateIssue(ctx, parent, "test"); err != nil {
|
||||
t.Fatalf("failed to create parent: %v", err)
|
||||
}
|
||||
|
||||
// Create a discovered issue with discovered-from dependency
|
||||
// This should inherit the parent's source_repo
|
||||
discovered := &types.Issue{
|
||||
Title: "Discovered bug",
|
||||
Priority: 1,
|
||||
Status: types.StatusOpen,
|
||||
IssueType: types.TypeBug,
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
// Simulate what happens in create.go when --deps discovered-from:parent is used
|
||||
// The source_repo should be inherited from the parent
|
||||
parentIssue, err := s.GetIssue(ctx, parent.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get parent issue: %v", err)
|
||||
}
|
||||
if parentIssue.SourceRepo != "" {
|
||||
discovered.SourceRepo = parentIssue.SourceRepo
|
||||
}
|
||||
|
||||
if err := s.CreateIssue(ctx, discovered, "test"); err != nil {
|
||||
t.Fatalf("failed to create discovered issue: %v", err)
|
||||
}
|
||||
|
||||
// Add discovered-from dependency
|
||||
dep := &types.Dependency{
|
||||
IssueID: discovered.ID,
|
||||
DependsOnID: parent.ID,
|
||||
Type: types.DepDiscoveredFrom,
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
if err := s.AddDependency(ctx, dep, "test"); err != nil {
|
||||
t.Fatalf("failed to add dependency: %v", err)
|
||||
}
|
||||
|
||||
// Verify the discovered issue inherited the source_repo
|
||||
retrievedIssue, err := s.GetIssue(ctx, discovered.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get discovered issue: %v", err)
|
||||
}
|
||||
|
||||
if retrievedIssue.SourceRepo != parent.SourceRepo {
|
||||
t.Errorf("expected source_repo %q, got %q", parent.SourceRepo, retrievedIssue.SourceRepo)
|
||||
}
|
||||
|
||||
if retrievedIssue.SourceRepo != "/path/to/custom/repo" {
|
||||
t.Errorf("expected source_repo '/path/to/custom/repo', got %q", retrievedIssue.SourceRepo)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user