(t *testing.T)
| 228 | } |
| 229 | |
| 230 | func TestBelongsToDefaultValue(t *testing.T) { |
| 231 | type Org struct { |
| 232 | ID string |
| 233 | } |
| 234 | type BelongsToUser struct { |
| 235 | OrgID string |
| 236 | Org Org `gorm:"default:NULL"` |
| 237 | } |
| 238 | |
| 239 | tx := DB.Session(&gorm.Session{}) |
| 240 | tx.Config.DisableForeignKeyConstraintWhenMigrating = true |
| 241 | AssertEqual(t, DB.Config.DisableForeignKeyConstraintWhenMigrating, false) |
| 242 | |
| 243 | tx.Migrator().DropTable(&BelongsToUser{}, &Org{}) |
| 244 | tx.AutoMigrate(&BelongsToUser{}, &Org{}) |
| 245 | |
| 246 | user := &BelongsToUser{ |
| 247 | Org: Org{ |
| 248 | ID: "BelongsToUser_Org_1", |
| 249 | }, |
| 250 | } |
| 251 | err := DB.Create(&user).Error |
| 252 | AssertEqual(t, err, nil) |
| 253 | } |
| 254 | |
| 255 | func TestBelongsToAssociationUnscoped(t *testing.T) { |
| 256 | type ItemParent struct { |
nothing calls this directly
no test coverage detected