summaryrefslogtreecommitdiff
path: root/internal/lsp/build_prompts_table_test.go
blob: bc4f031f07afe54bd52538dca21944bacde41b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package lsp

import "testing"

func TestBuildPrompts_Table(t *testing.T) {
	p := CompletionParams{TextDocument: TextDocumentIdentifier{URI: "file:///x.go"}, Position: Position{Line: 5, Character: 7}}
	cases := []struct {
		name     string
		inParams bool
	}{
		{"generic", false},
		{"in_params", true},
	}
	for _, c := range cases {
		s := newTestServer()
		msgs := s.buildCompletionMessages(false, false, "", c.inParams, p, "above", "current", "below", "func ctx")
		if len(msgs) < 2 || msgs[0].Role != "system" || msgs[1].Role != "user" {
			t.Fatalf("%s: unexpected messages", c.name)
		}
		if msgs[0].Content == "" || msgs[1].Content == "" {
			t.Fatalf("%s: prompts empty", c.name)
		}
	}
}