返回 DeepSeek-Reasonix
rebuild_graph_test.go
根目录 / internal / boot / rebuild_graph_test.go
1 package boot
2
3 import (
4 "testing"
5
6 "reasonix/internal/extension"
7 "reasonix/internal/extensioncontract"
8 )
9
10 func TestRebuildFromGraphUsesPreviousAsFrom(t *testing.T) {
11 // Synthetic: from has plugin/a, to is empty → must not classify as no-op.
12 from, err := extension.BuildDependencyGraph([]extension.ComponentDescriptor{
13 {ID: "plugin/a", Provides: []extensioncontract.Capability{{
14 Key: extensioncontract.CapabilityKey{Namespace: "plugin/a", Kind: "ui", ID: "x"},
15 Version: "1.0.0", SchemaHash: "sha256:a",
16 }}},
17 })
18 if err != nil {
19 t.Fatal(err)
20 }
21 // Empty to graph.
22 to := &extension.DependencyGraph{
23 Components: map[extension.ComponentID]extension.ComponentDescriptor{},
24 Edges: map[extension.ComponentID][]extension.ComponentID{},
25 Providers: map[string][]extension.ComponentID{},
26 }
27 plan := extension.DiffRuntimePlan(from, to, 1, 2)
28 if plan.IsNoOp() {
29 t.Fatal("removing a component must not be a no-op plan")
30 }
31 if len(plan.Removed) == 0 {
32 t.Fatalf("expected removed, plan=%+v", plan)
33 }
34 // Diff against self is no-op (the bug we fixed was using current for both).
35 self := extension.DiffRuntimePlan(from, from, 1, 2)
36 if !self.IsNoOp() {
37 t.Fatal("same graph should be no-op")
38 }
39 }
40
40 lines GO