// Ensure that if Replace() is called from a Post() callback, we discard
// any previously-existing field values.
Ensure that if Replace() is called from a Post() callback, we discard
any previously-existing field values.
// Ensure that if Replace () is called from a Post () callback we discard // any previously - existing field values .
func TestPostReplaceIgnoresOldValues(t *testing.T) {
	a := assert.New(t)
	d, _ := l.NewContainer(false)
	d2, changed, err := d.WalkTarget(func(ctx l.TargetContext, x l.Target) l.TargetDecision {
		if _, ok := x.(*l.ContainerType); ok {
			return ctx.Continue().Post(func(ctx l.TargetContext, x l.Target) l.TargetDecision {
				return ctx.Continue().Replace(&l.ContainerType{ByRef: l.ByRefType{Val: "PostReplace"}})
			})
		}
		return ctx.Continue()
	})
	if !a.NoError(err) {
		return
	}
	a.True(changed)
	a.NotEqual(d, d2)
	a.Equal("PostReplace", d2.ByRef.Val)
	a.Nil(d2.ByRefPtr)
}
func TestPostReplaceIgnoresOldValues ( t * testing . T ) { a := assert . New ( t ) d , _ := l . NewContainer ( false ) d2 , changed , err := d . WalkTarget ( func ( ctx l . TargetContext , x l . Target ) l . TargetDecision { if _ , ok := x . ( * l . ContainerType ) ; ok { return ctx . Continue ( ) . Post ( func ( ctx l . TargetContext , x l . Target ) l . TargetDecision { return ctx . Continue ( ) . Replace ( & l . ContainerType { ByRef : l . ByRefType { Val : " " } } ) } ) } return ctx . Continue ( ) } ) if ! a . NoError ( err ) { return } a . True ( changed ) a . NotEqual ( d , d2 ) a . Equal ( " " , d2 . ByRef . Val ) a . Nil ( d2 . ByRefPtr ) }
Ensure that if Replace() is called from a Post() callback, we discard
any previously-existing field values.
Ensure that if Replace () is called from a Post () callback we discard any previously - existing field values .