grokkit/internal/docs/docs_test.go

31 lines
725 B
Go
Raw Permalink Normal View History

package docs
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBuildDocsMessages(t *testing.T) {
tests := []struct {
language string
code string
styleCheck string
}{
{language: "Go", code: "func Foo() {}", styleCheck: "godoc"},
{language: "Python", code: "def foo(): pass", styleCheck: "PEP 257"},
{language: "JavaScript", code: "function foo() {}", styleCheck: "JSDoc"},
}
for _, tt := range tests {
t.Run(tt.language, func(t *testing.T) {
msgs := BuildDocsMessages(tt.language, tt.code)
assert.Len(t, msgs, 2)
assert.Equal(t, "system", msgs[0]["role"])
assert.Equal(t, "user", msgs[1]["role"])
assert.Contains(t, msgs[0]["content"], tt.styleCheck)
})
}
}