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

Function TestComputeDiff_AddColumn

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

Source from the content-addressed store, hash-verified

226}
227
228func TestComputeDiff_AddColumn(t *testing.T) {
229 current := &sdata.DBInfo{
230 Type: "postgres",
231 Tables: []sdata.DBTable{
232 {
233 Name: "users",
234 Columns: []sdata.DBColumn{
235 {Name: "id", Type: "bigint", PrimaryKey: true},
236 },
237 },
238 },
239 }
240
241 expected := &sdata.DBInfo{
242 Type: "postgres",
243 Tables: []sdata.DBTable{
244 {
245 Name: "users",
246 Columns: []sdata.DBColumn{
247 {Name: "id", Type: "bigint", PrimaryKey: true},
248 {Name: "email", Type: "text", NotNull: true},
249 },
250 },
251 },
252 }
253
254 ops := computeDiff(current, expected, DiffOptions{Destructive: false})
255
256 if len(ops) == 0 {
257 t.Fatal("expected at least one operation")
258 }
259
260 found := false
261 for _, op := range ops {
262 if op.Type == "add_column" && op.Column == "email" {
263 found = true
264 if !strings.Contains(op.SQL, "ADD COLUMN") {
265 t.Errorf("expected ADD COLUMN in SQL, got: %s", op.SQL)
266 }
267 }
268 }
269
270 if !found {
271 t.Error("expected add_column operation for email column")
272 }
273}
274
275func TestComputeDiff_DropColumn_NotDestructive(t *testing.T) {
276 current := &sdata.DBInfo{

Callers

nothing calls this directly

Calls 2

computeDiffFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected