Skip to content

Commit

Permalink
Add test for db schema with a CHECK constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-farries committed Jan 17, 2024
1 parent 82b4fad commit 88f2ece
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pkg/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,44 @@ func TestReadSchema(t *testing.T) {
},
},
},
{
name: "check constraint",
createStmt: "CREATE TABLE public.table1 (id int PRIMARY KEY, age INTEGER, CONSTRAINT age_check CHECK (age > 18));",
wantSchema: &schema.Schema{
Name: "public",
Tables: map[string]schema.Table{
"table1": {
Name: "table1",
Columns: map[string]schema.Column{
"id": {
Name: "id",
Type: "integer",
Nullable: false,
Unique: true,
},
"age": {
Name: "age",
Type: "integer",
Nullable: true,
},
},
PrimaryKey: []string{"id"},
Indexes: map[string]schema.Index{
"table1_pkey": {
Name: "table1_pkey",
},
},
CheckConstraints: map[string]schema.CheckConstraint{
"age_check": {
Name: "age_check",
Columns: []string{"age"},
Definition: "CHECK ((age > 18))",
},
},
},
},
},
},
}

// init the state
Expand Down

0 comments on commit 88f2ece

Please sign in to comment.