style: reformat test tables

This commit is contained in:
2026-10-03 21:41:54 +02:00
parent bed80b046b
commit b49859537b
12 changed files with 146 additions and 59 deletions
+13 -5
View File
@@ -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 {
+24 -9
View File
@@ -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++ {
+9 -3
View File
@@ -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 {
+4 -2
View File
@@ -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")