Remove skipped tests and unreachable RPC methods (bd-212, bd-213)
bd-212: Delete 3 permanently skipped test functions (~150 LOC) - TestImportDependencyUpdates (import_collision_test.go) - TestImportChainDependencies (import_collision_test.go) - TestUpdateDependencyReferences (collision_test.go) bd-213: Remove 4 unreachable RPC methods (~80 LOC) - Server.GetLastImportTime - Server.SetLastImportTime - Server.findJSONLPath - Client.Import All tests pass. Phase 1 dead code cleanup continues.
This commit is contained in:
@@ -911,145 +911,6 @@ func TestRemapCollisions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// SKIPPED: This test expects the OLD buggy behavior where existing issue dependencies
|
||||
// get updated during collision resolution. Per GH issue #120, existing dependencies
|
||||
// should be preserved, not updated. This test needs to be rewritten to test the correct
|
||||
// semantics (only update dependencies belonging to remapped issues, not existing ones).
|
||||
func TestUpdateDependencyReferences(t *testing.T) {
|
||||
t.Skip("Test expects old buggy behavior - needs rewrite for GH#120 fix")
|
||||
// Create temporary database
|
||||
tmpDir, err := os.MkdirTemp("", "dep-remap-test-*")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temp dir: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
dbPath := filepath.Join(tmpDir, "test.db")
|
||||
store, err := New(dbPath)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create storage: %v", err)
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Create issues
|
||||
issue1 := &types.Issue{
|
||||
ID: "bd-1",
|
||||
Title: "Issue 1",
|
||||
Description: "First issue",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeTask,
|
||||
}
|
||||
|
||||
issue2 := &types.Issue{
|
||||
ID: "bd-2",
|
||||
Title: "Issue 2",
|
||||
Description: "Second issue",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeTask,
|
||||
}
|
||||
|
||||
issue3 := &types.Issue{
|
||||
ID: "bd-3",
|
||||
Title: "Issue 3",
|
||||
Description: "Third issue",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeTask,
|
||||
}
|
||||
|
||||
// Create the new (remapped) issue
|
||||
issue100 := &types.Issue{
|
||||
ID: "bd-100",
|
||||
Title: "Remapped Issue (was bd-2)",
|
||||
Description: "This is the remapped version",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeTask,
|
||||
}
|
||||
|
||||
if err := store.CreateIssue(ctx, issue1, "test"); err != nil {
|
||||
t.Fatalf("failed to create issue1: %v", err)
|
||||
}
|
||||
if err := store.CreateIssue(ctx, issue2, "test"); err != nil {
|
||||
t.Fatalf("failed to create issue2: %v", err)
|
||||
}
|
||||
if err := store.CreateIssue(ctx, issue3, "test"); err != nil {
|
||||
t.Fatalf("failed to create issue3: %v", err)
|
||||
}
|
||||
if err := store.CreateIssue(ctx, issue100, "test"); err != nil {
|
||||
t.Fatalf("failed to create issue100: %v", err)
|
||||
}
|
||||
|
||||
// Add dependencies
|
||||
// bd-1 depends on bd-2
|
||||
dep1 := &types.Dependency{
|
||||
IssueID: "bd-1",
|
||||
DependsOnID: "bd-2",
|
||||
Type: types.DepBlocks,
|
||||
}
|
||||
// bd-3 depends on bd-2
|
||||
dep2 := &types.Dependency{
|
||||
IssueID: "bd-3",
|
||||
DependsOnID: "bd-2",
|
||||
Type: types.DepBlocks,
|
||||
}
|
||||
|
||||
if err := store.AddDependency(ctx, dep1, "test"); err != nil {
|
||||
t.Fatalf("failed to add dep1: %v", err)
|
||||
}
|
||||
if err := store.AddDependency(ctx, dep2, "test"); err != nil {
|
||||
t.Fatalf("failed to add dep2: %v", err)
|
||||
}
|
||||
|
||||
// Create ID mapping (bd-2 was remapped to bd-100)
|
||||
idMapping := map[string]string{
|
||||
"bd-2": "bd-100",
|
||||
}
|
||||
|
||||
// Update dependency references
|
||||
if err := updateDependencyReferences(ctx, store, idMapping); err != nil {
|
||||
t.Fatalf("updateDependencyReferences failed: %v", err)
|
||||
}
|
||||
|
||||
// Verify dependencies were updated
|
||||
// bd-1 should now depend on bd-100
|
||||
deps1, err := store.GetDependencyRecords(ctx, "bd-1")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get deps for bd-1: %v", err)
|
||||
}
|
||||
if len(deps1) != 1 {
|
||||
t.Fatalf("expected 1 dependency for bd-1, got %d", len(deps1))
|
||||
}
|
||||
if deps1[0].DependsOnID != "bd-100" {
|
||||
t.Errorf("expected bd-1 to depend on bd-100, got %s", deps1[0].DependsOnID)
|
||||
}
|
||||
|
||||
// bd-3 should now depend on bd-100
|
||||
deps3, err := store.GetDependencyRecords(ctx, "bd-3")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get deps for bd-3: %v", err)
|
||||
}
|
||||
if len(deps3) != 1 {
|
||||
t.Fatalf("expected 1 dependency for bd-3, got %d", len(deps3))
|
||||
}
|
||||
if deps3[0].DependsOnID != "bd-100" {
|
||||
t.Errorf("expected bd-3 to depend on bd-100, got %s", deps3[0].DependsOnID)
|
||||
}
|
||||
|
||||
// Old dependency bd-2 should not have any dependencies anymore
|
||||
deps2, err := store.GetDependencyRecords(ctx, "bd-2")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get deps for bd-2: %v", err)
|
||||
}
|
||||
if len(deps2) != 0 {
|
||||
t.Errorf("expected 0 dependencies for bd-2, got %d", len(deps2))
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkReplaceIDReferences benchmarks the old approach (compiling regex every time)
|
||||
func BenchmarkReplaceIDReferences(b *testing.B) {
|
||||
// Simulate a realistic scenario: 10 ID mappings
|
||||
|
||||
Reference in New Issue
Block a user