MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestChange_ReasonTruncation

Function TestChange_ReasonTruncation

backend/api/mcp/tool_change_test.go:825–849  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

823}
824
825func TestChange_ReasonTruncation(t *testing.T) {
826 mock := newChangeMock(employeeDB())
827 s := newChangeTestServer(t, mock)
828
829 longReason := strings.Repeat("x", 2000)
830 result, _, err := s.handleChange(testContext(), nil, ChangeInput{
831 Database: "employee_db",
832 SQL: "ALTER TABLE x ADD COLUMN y INT",
833 Title: "Test",
834 Reason: longReason,
835 })
836 require.NoError(t, err)
837 require.False(t, result.IsError)
838
839 text := result.Content[0].(*mcpsdk.TextContent).Text
840 require.Contains(t, text, "reason truncated to 1000 chars")
841
842 // Issue description should be truncated.
843 issue := mock.getCapturedIssue()
844 issueObj, ok := issue["issue"].(map[string]any)
845 require.True(t, ok)
846 desc, ok := issueObj["description"].(string)
847 require.True(t, ok)
848 require.Len(t, desc, 1000) // 997 chars + "..."
849}
850
851// --- Partial failure tests ---
852

Callers

nothing calls this directly

Calls 7

newChangeMockFunction · 0.85
employeeDBFunction · 0.85
newChangeTestServerFunction · 0.85
testContextFunction · 0.85
handleChangeMethod · 0.80
getCapturedIssueMethod · 0.80
LenMethod · 0.80

Tested by

no test coverage detected