返回 DeepSeek-Reasonix
plugin_packages_app_test.go
根目录 / desktop / plugin_packages_app_test.go
1 package main
2
3 import (
4 "testing"
5
6 "reasonix/internal/command"
7 )
8
9 func TestDecoratePluginCommandConflicts(t *testing.T) {
10 view := PluginView{
11 Name: "pwf",
12 Enabled: true,
13 CommandDetails: []PluginCommandView{
14 {Name: "plan", Invocation: "/pwf:plan"},
15 {Name: "status", Invocation: "/pwf:status"},
16 {Name: "new", Invocation: "/pwf:new"},
17 },
18 }
19 decoratePluginCommandConflicts(&view, []command.Command{
20 {Name: "plan", Plugin: "pwf", ShortName: "plan", Hidden: true},
21 {Name: "pwf:plan", Plugin: "pwf", ShortName: "plan"},
22 {Name: "pwf:status", Description: "explicit command"},
23 })
24
25 plan := view.CommandDetails[0]
26 if plan.Shadowed {
27 t.Fatalf("canonical plan should be available: %+v", plan)
28 }
29 if status := view.CommandDetails[1]; !status.Shadowed || status.ShadowedByPlugin != "" {
30 t.Fatalf("occupied canonical status = %+v", status)
31 }
32 if fresh := view.CommandDetails[2]; fresh.Shadowed {
33 t.Fatalf("command absent from a stale active session must not be reported as overridden: %+v", fresh)
34 }
35 }
36
37 func TestDecoratePluginCommandConflictNamesWinningPlugin(t *testing.T) {
38 view := PluginView{Name: "alpha", Enabled: true, CommandDetails: []PluginCommandView{{Name: "plan"}}}
39 decoratePluginCommandConflicts(&view, []command.Command{
40 {Name: "alpha:plan", Plugin: "beta", ShortName: "alpha:plan"},
41 })
42 got := view.CommandDetails[0]
43 if !got.Shadowed || got.ShadowedByPlugin != "beta" {
44 t.Fatalf("plugin conflict = %+v", got)
45 }
46 }
47
47 lines GO