summaryrefslogtreecommitdiff
path: root/internal/lsp/provider_native_success_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/lsp/provider_native_success_test.go')
-rw-r--r--internal/lsp/provider_native_success_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/lsp/provider_native_success_test.go b/internal/lsp/provider_native_success_test.go
index dd1abcd..bfcb0b6 100644
--- a/internal/lsp/provider_native_success_test.go
+++ b/internal/lsp/provider_native_success_test.go
@@ -60,3 +60,34 @@ func TestProviderNativeCompletion_IndentWithDoubleOpen(t *testing.T) {
t.Fatalf("expected indentation applied, got %q", got)
}
}
+
+type fakeCompleterCapture struct{ lastPrompt string }
+
+func (fakeCompleterCapture) Chat(context.Context, []llm.Message, ...llm.RequestOption) (string, error) { return "", nil }
+func (fakeCompleterCapture) Name() string { return "prov" }
+func (fakeCompleterCapture) DefaultModel() string { return "m" }
+func (f *fakeCompleterCapture) CodeCompletion(_ context.Context, prompt string, suffix string, n int, language string, temperature float64) ([]string, error) {
+ f.lastPrompt = prompt
+ return []string{"SUG"}, nil
+}
+
+func TestProviderNativeCompletion_UsesPromptTemplate(t *testing.T) {
+ s := newTestServer()
+ cap := &fakeCompleterCapture{}
+ s.llmClient = cap
+ s.promptNativeCompletion = "NATIVE {{path}} {{before}}"
+ uri := "file:///x.go"
+ s.setDocument(uri, "AAA\nBBB\nCCC")
+ current := "fmt."
+ // Cursor at line 1, char 1 -> before should be "AAA\nB"
+ p := CompletionParams{TextDocument: TextDocumentIdentifier{URI: uri}, Position: Position{Line: 1, Character: 1}}
+ if _, ok := s.tryProviderNativeCompletion(current, p, "", "", "func f(){}", "doc", false, "", false); !ok {
+ t.Fatalf("expected provider-native path")
+ }
+ if cap.lastPrompt == "" {
+ t.Fatalf("expected captured prompt")
+ }
+ if cap.lastPrompt != "NATIVE /x.go AAA\nB" {
+ t.Fatalf("unexpected prompt: %q", cap.lastPrompt)
+ }
+}