style: reformat test tables
This commit is contained in:
@@ -219,11 +219,19 @@ func TestFormatDefaultValue(t *testing.T) {
|
||||
in any
|
||||
want string
|
||||
}{
|
||||
{"now()", "sql`now()`"}, {"CURRENT_TIMESTAMP", "sql`now()`"},
|
||||
{"gen_random_uuid()", "sql`gen_random_uuid()`"}, {"uuid_generate_v4()", "sql`gen_random_uuid()`"},
|
||||
{"42", "42"}, {"-1.5", "-1.5"}, {"it's", `'it\'s'`}, {"plain", "'plain'"},
|
||||
{true, "true"}, {false, "false"},
|
||||
{7, "7"}, {int64(8), "8"}, {2.5, "2.5"},
|
||||
{"now()", "sql`now()`"},
|
||||
{"CURRENT_TIMESTAMP", "sql`now()`"},
|
||||
{"gen_random_uuid()", "sql`gen_random_uuid()`"},
|
||||
{"uuid_generate_v4()", "sql`gen_random_uuid()`"},
|
||||
{"42", "42"},
|
||||
{"-1.5", "-1.5"},
|
||||
{"it's", `'it\'s'`},
|
||||
{"plain", "'plain'"},
|
||||
{true, "true"},
|
||||
{false, "false"},
|
||||
{7, "7"},
|
||||
{int64(8), "8"},
|
||||
{2.5, "2.5"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := tm.formatDefaultValue(tt.in); got != tt.want {
|
||||
|
||||
@@ -13,15 +13,30 @@ func TestSQLTypeToPrisma(t *testing.T) {
|
||||
schema.Enums = append(schema.Enums, &models.Enum{Name: "Role", Values: []string{"A"}})
|
||||
|
||||
tests := []struct{ in, want string }{
|
||||
{"text", "String"}, {"varchar(255)", "String"}, {"character varying", "String"}, {"char(1)", "String"},
|
||||
{"boolean", "Boolean"}, {"bool", "Boolean"},
|
||||
{"integer", "Int"}, {"int", "Int"}, {"int4", "Int"},
|
||||
{"bigint", "BigInt"}, {"int8", "BigInt"}, {"BIGINT", "BigInt"},
|
||||
{"double precision", "Float"}, {"float8", "Float"},
|
||||
{"numeric(10,2)", "Decimal"}, {"decimal", "Decimal"},
|
||||
{"timestamp", "DateTime"}, {"timestamptz", "DateTime"}, {"date", "DateTime"},
|
||||
{"jsonb", "Json"}, {"json", "Json"}, {"bytea", "Bytes"},
|
||||
{"role", "Role"}, {"unknown_type", "String"},
|
||||
{"text", "String"},
|
||||
{"varchar(255)", "String"},
|
||||
{"character varying", "String"},
|
||||
{"char(1)", "String"},
|
||||
{"boolean", "Boolean"},
|
||||
{"bool", "Boolean"},
|
||||
{"integer", "Int"},
|
||||
{"int", "Int"},
|
||||
{"int4", "Int"},
|
||||
{"bigint", "BigInt"},
|
||||
{"int8", "BigInt"},
|
||||
{"BIGINT", "BigInt"},
|
||||
{"double precision", "Float"},
|
||||
{"float8", "Float"},
|
||||
{"numeric(10,2)", "Decimal"},
|
||||
{"decimal", "Decimal"},
|
||||
{"timestamp", "DateTime"},
|
||||
{"timestamptz", "DateTime"},
|
||||
{"date", "DateTime"},
|
||||
{"jsonb", "Json"},
|
||||
{"json", "Json"},
|
||||
{"bytea", "Bytes"},
|
||||
{"role", "Role"},
|
||||
{"unknown_type", "String"},
|
||||
}
|
||||
// Repeat: the mapping used to depend on map iteration order.
|
||||
for i := 0; i < 50; i++ {
|
||||
|
||||
@@ -140,9 +140,15 @@ func TestFormatDefaultValue(t *testing.T) {
|
||||
in any
|
||||
want string
|
||||
}{
|
||||
{"now()", "now()"}, {"gen_random_uuid()", "uuid()"}, {"uuid_generate_v4()", "uuid()"},
|
||||
{"hello", `"hello"`}, {true, "true"}, {false, "false"},
|
||||
{42, "42"}, {int64(7), "7"}, {1.5, "1.5"},
|
||||
{"now()", "now()"},
|
||||
{"gen_random_uuid()", "uuid()"},
|
||||
{"uuid_generate_v4()", "uuid()"},
|
||||
{"hello", `"hello"`},
|
||||
{true, "true"},
|
||||
{false, "false"},
|
||||
{42, "42"},
|
||||
{int64(7), "7"},
|
||||
{1.5, "1.5"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := w.formatDefaultValue(tt.in); got != tt.want {
|
||||
|
||||
@@ -11,8 +11,10 @@ import (
|
||||
)
|
||||
|
||||
func TestColumnTypesSurviveRoundTrip(t *testing.T) {
|
||||
types := []string{"integer", "boolean", "timestamp", "text", "uuid", "jsonb", "bigint",
|
||||
"varchar(255)", "char(3)", "numeric(10,2)", "timestamptz", "smallint", "date", "double precision"}
|
||||
types := []string{
|
||||
"integer", "boolean", "timestamp", "text", "uuid", "jsonb", "bigint",
|
||||
"varchar(255)", "char(3)", "numeric(10,2)", "timestamptz", "smallint", "date", "double precision",
|
||||
}
|
||||
|
||||
tbl := models.InitTable("things", "public")
|
||||
id := models.InitColumn("id", "things", "public")
|
||||
|
||||
Reference in New Issue
Block a user