MCPcopy Index your code
hub / github.com/dosco/graphjin / TestComputeDiff_DropColumn_Destructive

Function TestComputeDiff_DropColumn_Destructive

core/schema_diff_test.go:311–353  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

309}
310
311func TestComputeDiff_DropColumn_Destructive(t *testing.T) {
312 current := &sdata.DBInfo{
313 Type: "postgres",
314 Tables: []sdata.DBTable{
315 {
316 Name: "users",
317 Columns: []sdata.DBColumn{
318 {Name: "id", Type: "bigint", PrimaryKey: true},
319 {Name: "old_column", Type: "text"},
320 },
321 },
322 },
323 }
324
325 expected := &sdata.DBInfo{
326 Type: "postgres",
327 Tables: []sdata.DBTable{
328 {
329 Name: "users",
330 Columns: []sdata.DBColumn{
331 {Name: "id", Type: "bigint", PrimaryKey: true},
332 },
333 },
334 },
335 }
336
337 // With destructive flag
338 ops := computeDiff(current, expected, DiffOptions{Destructive: true})
339
340 found := false
341 for _, op := range ops {
342 if op.Type == "drop_column" && op.Column == "old_column" {
343 found = true
344 if !op.Danger {
345 t.Error("drop_column operation should be marked as dangerous")
346 }
347 }
348 }
349
350 if !found {
351 t.Error("expected drop_column operation when destructive is true")
352 }
353}
354
355func TestComputeDiff_DropTable_Destructive(t *testing.T) {
356 current := &sdata.DBInfo{

Callers

nothing calls this directly

Calls 2

computeDiffFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected