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:
@@ -537,3 +537,56 @@ func TestDatabaseHandshake(t *testing.T) {
|
||||
t.Errorf("Create without ExpectedDB should succeed (backward compat): %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreate_DiscoveredFromInheritsSourceRepo(t *testing.T) {
|
||||
_, client, cleanup := setupTestServer(t)
|
||||
defer cleanup()
|
||||
|
||||
// Create a parent issue
|
||||
parentArgs := &CreateArgs{
|
||||
Title: "Parent issue",
|
||||
IssueType: "task",
|
||||
Priority: 1,
|
||||
}
|
||||
|
||||
parentResp, err := client.Create(parentArgs)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create parent: %v", err)
|
||||
}
|
||||
|
||||
var parentIssue types.Issue
|
||||
if err := json.Unmarshal(parentResp.Data, &parentIssue); err != nil {
|
||||
t.Fatalf("Failed to unmarshal parent: %v", err)
|
||||
}
|
||||
|
||||
// Create discovered issue with discovered-from dependency
|
||||
// The logic in handleCreate should check for discovered-from dependencies
|
||||
// and inherit the parent's source_repo
|
||||
discoveredArgs := &CreateArgs{
|
||||
Title: "Discovered bug",
|
||||
IssueType: "bug",
|
||||
Priority: 1,
|
||||
Dependencies: []string{"discovered-from:" + parentIssue.ID},
|
||||
}
|
||||
|
||||
discoveredResp, err := client.Create(discoveredArgs)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create discovered issue: %v", err)
|
||||
}
|
||||
|
||||
var discoveredIssue types.Issue
|
||||
if err := json.Unmarshal(discoveredResp.Data, &discoveredIssue); err != nil {
|
||||
t.Fatalf("Failed to unmarshal discovered issue: %v", err)
|
||||
}
|
||||
|
||||
// Verify the issue was created successfully
|
||||
if discoveredIssue.Title != "Discovered bug" {
|
||||
t.Errorf("Expected title 'Discovered bug', got %s", discoveredIssue.Title)
|
||||
}
|
||||
|
||||
// Note: To fully test source_repo inheritance, we'd need to:
|
||||
// 1. Create a parent with custom source_repo (requires direct storage access)
|
||||
// 2. Verify the discovered issue inherited it
|
||||
// The logic is implemented in server_issues_epics.go handleCreate
|
||||
// and tested via the cmd/bd test which has direct storage access
|
||||
}
|
||||
|
||||
@@ -99,6 +99,42 @@ func (s *Server) handleCreate(req *Request) Response {
|
||||
}
|
||||
|
||||
ctx := s.reqCtx(req)
|
||||
|
||||
// Check if any dependencies are discovered-from type
|
||||
// If so, inherit source_repo from the parent issue
|
||||
var discoveredFromParentID string
|
||||
for _, depSpec := range createArgs.Dependencies {
|
||||
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, s.reqActor(req)); err != nil {
|
||||
return Response{
|
||||
Success: false,
|
||||
|
||||
Reference in New Issue
Block a user