MCPcopy
hub / github.com/uber-go/zap / assertCanBeReused

Function assertCanBeReused

exp/zapfield/zapfield_test.go:65–83  ·  exp/zapfield/zapfield_test.go::assertCanBeReused
(t testing.TB, field zap.Field)

Source from the content-addressed store, hash-verified

63}
64
65func assertCanBeReused(t testing.TB, field zap.Field) {
66 var wg sync.WaitGroup
67
68 for i := 0; i < 100; i++ {
69 enc := zapcore.NewMapObjectEncoder()
70
71 // Ensure using the field in multiple encoders in separate goroutines
72 // does not cause any races or panics.
73 wg.Add(1)
74 go func() {
75 defer wg.Done()
76 assert.NotPanics(t, func() {
77 field.AddTo(enc)
78 }, "Reusing a field should not cause issues")
79 }()
80 }
81
82 wg.Wait()
83}

Callers 1

TestFieldConstructorsFunction · 0.70

Calls 3

NewMapObjectEncoderFunction · 0.92
AddToMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected