knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/apis/duck/v1/test/fuzzer.go (about) 1 /* 2 Copyright 2020 The Knative Authors 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package test 18 19 import ( 20 "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" 21 "k8s.io/apimachinery/pkg/runtime/serializer" 22 "knative.dev/pkg/apis" 23 v1 "knative.dev/pkg/apis/duck/v1" 24 pkgfuzzer "knative.dev/pkg/apis/testing/fuzzer" 25 "sigs.k8s.io/randfill" 26 ) 27 28 var testConditions = apis.Conditions{{Type: apis.ConditionReady}, {Type: apis.ConditionSucceeded}} 29 30 // FuzzerFuncs includes fuzzing funcs for knative.dev/duck v1 types 31 // In particular it makes sure that Delivery has only valid BackoffPolicyType in it. 32 // 33 // For other examples see 34 // https://github.com/kubernetes/apimachinery/blob/master/pkg/apis/meta/fuzzer/fuzzer.go 35 var FuzzerFuncs = fuzzer.MergeFuzzerFuncs( 36 func(codecs serializer.CodecFactory) []interface{} { 37 return []interface{}{ 38 func(status *v1.Status, c randfill.Continue) { 39 c.FillNoCustom(status) // fuzz the Status 40 status.SetConditions(testConditions) 41 pkgfuzzer.FuzzConditions(status, c) 42 }, 43 } 44 }, 45 )