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

Function TestComputeDiff_CreateTable

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

Source from the content-addressed store, hash-verified

8)
9
10func TestComputeDiff_CreateTable(t *testing.T) {
11 current := &sdata.DBInfo{
12 Type: "postgres",
13 Tables: []sdata.DBTable{},
14 }
15
16 expected := &sdata.DBInfo{
17 Type: "postgres",
18 Tables: []sdata.DBTable{
19 {
20 Name: "users",
21 Columns: []sdata.DBColumn{
22 {Name: "id", Type: "bigint", PrimaryKey: true, NotNull: true},
23 {Name: "name", Type: "text", NotNull: true},
24 {Name: "email", Type: "text"},
25 },
26 },
27 },
28 }
29
30 ops := computeDiff(current, expected, DiffOptions{Destructive: false})
31
32 if len(ops) == 0 {
33 t.Fatal("expected at least one operation")
34 }
35
36 // Should have a create_table operation
37 found := false
38 for _, op := range ops {
39 if op.Type == "create_table" && op.Table == "users" {
40 found = true
41 if !strings.Contains(op.SQL, "CREATE TABLE") {
42 t.Errorf("expected CREATE TABLE in SQL, got: %s", op.SQL)
43 }
44 if !strings.Contains(op.SQL, `"id"`) {
45 t.Errorf("expected id column in SQL, got: %s", op.SQL)
46 }
47 }
48 }
49
50 if !found {
51 t.Error("expected create_table operation for users table")
52 }
53}
54
55func TestSupportsSchemaDDLBoundary(t *testing.T) {
56 for _, dbType := range []string{"postgres", "mysql", "mariadb", "sqlite", "mssql", "oracle", "snowflake"} {

Callers

nothing calls this directly

Calls 2

computeDiffFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected