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

Function TestPreloadGoroutine

tests/preload_test.go:239–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

237}
238
239func TestPreloadGoroutine(t *testing.T) {
240 var wg sync.WaitGroup
241
242 wg.Add(10)
243 for i := 0; i < 10; i++ {
244 go func() {
245 defer wg.Done()
246 var user2 []User
247 tx := DB.Where("id = ?", 1).Session(&gorm.Session{})
248
249 if err := tx.Preload("Team").Find(&user2).Error; err != nil {
250 t.Error(err)
251 }
252 }()
253 }
254 wg.Wait()
255}
256
257func TestPreloadWithDiffModel(t *testing.T) {
258 user := *GetUser("preload_with_diff_model", Config{Account: true})

Callers

nothing calls this directly

Calls 6

AddMethod · 0.80
SessionMethod · 0.80
WhereMethod · 0.65
FindMethod · 0.65
PreloadMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected