diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-24 23:21:43 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-24 23:21:43 +0300 |
| commit | c3c71345db9086392cd9b7529c7f5287009c226e (patch) | |
| tree | d227894ab900d6050cbe1418984526088a692db5 /internal/lsp/codeaction_custom_test.go | |
| parent | 127844a4ee481590ef53b6777d34bf2114cb3ab1 (diff) | |
Add runtime config store and reload command
Diffstat (limited to 'internal/lsp/codeaction_custom_test.go')
| -rw-r--r-- | internal/lsp/codeaction_custom_test.go | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/internal/lsp/codeaction_custom_test.go b/internal/lsp/codeaction_custom_test.go index 1ea4c3c..ea8ae82 100644 --- a/internal/lsp/codeaction_custom_test.go +++ b/internal/lsp/codeaction_custom_test.go @@ -7,6 +7,8 @@ import ( "log" "strings" "testing" + + "codeberg.org/snonux/hexai/internal/appconfig" ) // local copy of captureResponse for this test file @@ -27,24 +29,23 @@ func capResp(t *testing.T, buf *bytes.Buffer) Response { func TestHandleCodeAction_ListsCustomActions(t *testing.T) { var out bytes.Buffer - s := &Server{ - logger: log.New(io.Discard, "", 0), - docs: make(map[string]*document), - out: &out, - inlineOpen: ">", - inlineClose: ">", - inlineOpenChar: '>', - inlineCloseChar: '>', - chatSuffix: ">", - chatSuffixChar: '>', - chatPrefixes: []string{"?", "!", ":", ";"}, + cfg := appconfig.App{ + InlineOpen: ">", + InlineClose: ">", + ChatSuffix: ">", + ChatPrefixes: []string{"?", "!", ":", ";"}, + CustomActions: []appconfig.CustomAction{ + {ID: "extract", Title: "Extract function", Scope: "selection", Kind: "refactor.extract", Instruction: "Extract into function"}, + {ID: "fix", Title: "Fix diagnostics", Scope: "diagnostics", Kind: "quickfix", User: "Fix:\n{{diagnostics}}\n\n{{selection}}"}, + }, } - s.llmClient = fakeLLM{resp: "IGN"} - // Inject two custom actions - s.customActions = []CustomAction{ - {ID: "extract", Title: "Extract function", Scope: "selection", Kind: "refactor.extract", Instruction: "Extract into function"}, - {ID: "fix", Title: "Fix diagnostics", Scope: "diagnostics", Kind: "quickfix", User: "Fix:\n{{diagnostics}}\n\n{{selection}}"}, + s := &Server{ + logger: log.New(io.Discard, "", 0), + docs: make(map[string]*document), + out: &out, + cfg: cfg, } + s.llmClient = fakeLLM{resp: "ok"} // Prepare document and params uri := "file:///t.go" s.setDocument(uri, "package x\n\nfunc f(){}\n") @@ -82,11 +83,12 @@ func TestHandleCodeAction_ListsCustomActions(t *testing.T) { func TestResolveCodeAction_CustomInstructionAndUser(t *testing.T) { s := newTestServer() s.llmClient = fakeLLM{resp: "REPLACED"} - // one instruction-based and one user-based - s.customActions = []CustomAction{ + cfg := s.cfg + cfg.CustomActions = []appconfig.CustomAction{ {ID: "extract", Title: "Extract function", Scope: "selection", Kind: "refactor.extract", Instruction: "Extract into function"}, {ID: "fix", Title: "Fix diagnostics", Scope: "diagnostics", Kind: "quickfix", User: "Fix: {{diagnostics}}\n{{selection}}"}, } + s.cfg = cfg uri := "file:///t.go" p := CodeActionParams{TextDocument: TextDocumentIdentifier{URI: uri}, Range: Range{Start: Position{Line: 1}, End: Position{Line: 1, Character: 3}}} |
