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

Function TestChange_SDL

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

Source from the content-addressed store, hash-verified

211}
212
213func TestChange_SDL(t *testing.T) {
214 mock := newChangeMock(employeeDB())
215 s := newChangeTestServer(t, mock)
216
217 _, structured, err := s.handleChange(testContext(), nil, ChangeInput{
218 Database: "employee_db",
219 SQL: "CREATE TABLE users (id INT PRIMARY KEY);",
220 Title: "SDL change",
221 ChangeType: "SDL",
222 })
223 require.NoError(t, err)
224
225 output, ok := structured.(*ChangeOutput)
226 require.True(t, ok)
227 // changeType is reflected in the response but not sent to the API
228 // (the backend auto-detects MIGRATE vs SDL from sheet content).
229 require.Equal(t, "SDL", output.ResolvedChangeType)
230
231 // Verify plan spec does NOT include a type field (removed in migration 3.14).
232 plan := mock.getCapturedPlan()
233 planObj, ok := plan["plan"].(map[string]any)
234 require.True(t, ok)
235 specs, ok := planObj["specs"].([]any)
236 require.True(t, ok)
237 spec, ok := specs[0].(map[string]any)
238 require.True(t, ok)
239 cfg, ok := spec["changeDatabaseConfig"].(map[string]any)
240 require.True(t, ok)
241 _, hasType := cfg["type"]
242 require.False(t, hasType, "type field should not be sent to the API")
243}
244
245func TestChange_ReasonIncluded(t *testing.T) {
246 mock := newChangeMock(employeeDB())

Callers

nothing calls this directly

Calls 7

newChangeMockFunction · 0.85
employeeDBFunction · 0.85
newChangeTestServerFunction · 0.85
testContextFunction · 0.85
handleChangeMethod · 0.80
getCapturedPlanMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected