MCPcopy
hub / github.com/go-gorm/gorm / TestPropagateUnscoped

Function TestPropagateUnscoped

tests/hooks_test.go:590–611  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

588}
589
590func TestPropagateUnscoped(t *testing.T) {
591 _DB, err := OpenTestConnection(&gorm.Config{
592 PropagateUnscoped: true,
593 })
594 if err != nil {
595 log.Printf("failed to connect database, got error %v", err)
596 os.Exit(1)
597 }
598
599 _DB.Migrator().DropTable(&Product6{}, &ProductItem2{})
600 _DB.AutoMigrate(&Product6{}, &ProductItem2{})
601
602 p := Product6{
603 Name: "unique_code",
604 Item: &ProductItem2{},
605 }
606 _DB.Model(&Product6{}).Create(&p)
607
608 if err := _DB.Unscoped().Delete(&p).Error; err != nil {
609 t.Fatalf("unscoped did not propagate")
610 }
611}

Callers

nothing calls this directly

Calls 9

OpenTestConnectionFunction · 0.85
PrintfMethod · 0.80
ModelMethod · 0.80
DropTableMethod · 0.65
MigratorMethod · 0.65
AutoMigrateMethod · 0.65
CreateMethod · 0.65
DeleteMethod · 0.65
UnscopedMethod · 0.45

Tested by

no test coverage detected