Files
platforms/backend/api/internal/models/entity_test.go

22 lines
508 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package models
import (
"reflect"
"testing"
"gorm.io/gorm"
)
func TestEntityDeletedAtEnablesSoftDelete(t *testing.T) {
field, ok := reflect.TypeOf(Entity{}).FieldByName("DeletedAt")
if !ok {
t.Fatal("Entity 缺少 DeletedAt 软删除字段")
}
if field.Type != reflect.TypeOf(gorm.DeletedAt{}) {
t.Fatalf("DeletedAt 类型为 %v期望 gorm.DeletedAt", field.Type)
}
if got := field.Tag.Get("gorm"); got != "index" {
t.Fatalf("DeletedAt gorm 标签为 %q期望 %q", got, "index")
}
}