@@ -60,6 +60,9 @@ type KRMTypedFuzzer[ProtoT proto.Message, SpecType any, StatusType any] struct {
6060 UnimplementedFields sets.Set [string ]
6161 SpecFields sets.Set [string ]
6262 StatusFields sets.Set [string ]
63+
64+ FilterSpec func (in ProtoT )
65+ FilterStatus func (in ProtoT )
6366}
6467
6568// SpecField marks the specified fieldPath as round-tripping to/from the Spec
@@ -133,13 +136,15 @@ func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) FuzzSpec(t *testing.T, se
133136 fuzzer := NewFuzzTest (f .ProtoType , f .SpecFromProto , f .SpecToProto )
134137 fuzzer .IgnoreFields = f .StatusFields
135138 fuzzer .UnimplementedFields = f .UnimplementedFields
139+ fuzzer .Filter = f .FilterSpec
136140 fuzzer .Fuzz (t , seed )
137141}
138142
139143func (f * KRMTypedFuzzer [ProtoT , SpecType , StatusType ]) FuzzStatus (t * testing.T , seed int64 ) {
140144 fuzzer := NewFuzzTest (f .ProtoType , f .StatusFromProto , f .StatusToProto )
141145 fuzzer .IgnoreFields = f .SpecFields
142146 fuzzer .UnimplementedFields = f .UnimplementedFields
147+ fuzzer .Filter = f .FilterStatus
143148 fuzzer .Fuzz (t , seed )
144149}
145150
@@ -172,6 +177,8 @@ type FuzzTest[ProtoT proto.Message, KRMType any] struct {
172177
173178 UnimplementedFields sets.Set [string ]
174179 IgnoreFields sets.Set [string ]
180+
181+ Filter func (in ProtoT )
175182}
176183
177184func NewFuzzTest [ProtoT proto.Message , KRMType any ](protoType ProtoT , fromProto func (ctx * direct.MapContext , in ProtoT ) * KRMType , toProto func (ctx * direct.MapContext , in * KRMType ) ProtoT ) * FuzzTest [ProtoT , KRMType ] {
@@ -200,6 +207,10 @@ func (f *FuzzTest[ProtoT, KRMType]) Fuzz(t *testing.T, seed int64) {
200207 }
201208 fuzz .Visit ("" , p1 .ProtoReflect (), nil , clearFields )
202209
210+ if f .Filter != nil {
211+ f .Filter (p1 )
212+ }
213+
203214 ctx := & direct.MapContext {}
204215 krm := f .FromProto (ctx , p1 )
205216 if ctx .Err () != nil {
0 commit comments