This repository has been archived by the owner on Jun 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* DeepCopy the entire set of conditions * remove unused function * add fuzzing testing
- Loading branch information
1 parent
d8743c5
commit 4f0b170
Showing
14 changed files
with
1,856 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2020 The Knative Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
pkgfuzzer "knative.dev/pkg/apis/testing/fuzzer" | ||
"knative.dev/pkg/apis/testing/roundtrip" | ||
|
||
"knative.dev/eventing-contrib/kafka/source/pkg/apis/sources/v1beta1" | ||
) | ||
|
||
func TestSourcesRoundTripTypesToJSON(t *testing.T) { | ||
scheme := runtime.NewScheme() | ||
utilruntime.Must(AddToScheme(scheme)) | ||
|
||
fuzzerFuncs := fuzzer.MergeFuzzerFuncs( | ||
pkgfuzzer.Funcs, | ||
v1beta1.FuzzerFuncs, | ||
) | ||
roundtrip.ExternalTypesViaJSON(t, scheme, fuzzerFuncs) | ||
} | ||
|
||
func TestSourceRoundTripTypesToAlphaHub(t *testing.T) { | ||
scheme := runtime.NewScheme() | ||
|
||
sb := runtime.SchemeBuilder{ | ||
AddToScheme, | ||
v1beta1.AddToScheme, | ||
} | ||
|
||
utilruntime.Must(sb.AddToScheme(scheme)) | ||
|
||
hubs := runtime.NewScheme() | ||
hubs.AddKnownTypes(SchemeGroupVersion, | ||
&KafkaSource{}, | ||
) | ||
|
||
fuzzerFuncs := fuzzer.MergeFuzzerFuncs( | ||
pkgfuzzer.Funcs, | ||
v1beta1.FuzzerFuncs, | ||
) | ||
|
||
roundtrip.ExternalTypesViaHub(t, scheme, hubs, fuzzerFuncs) | ||
} |
5 changes: 5 additions & 0 deletions
5
kafka/source/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright 2020 The Knative Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
fuzz "github.com/google/gofuzz" | ||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" | ||
"k8s.io/apimachinery/pkg/runtime/serializer" | ||
pkgfuzzer "knative.dev/pkg/apis/testing/fuzzer" | ||
) | ||
|
||
// FuzzerFuncs includes fuzzing funcs for sources.knative.dev v1beta1 types | ||
// | ||
// For other examples see | ||
// https://github.com/kubernetes/apimachinery/blob/master/pkg/apis/meta/fuzzer/fuzzer.go | ||
var FuzzerFuncs = fuzzer.MergeFuzzerFuncs( | ||
func(codecs serializer.CodecFactory) []interface{} { | ||
return []interface{}{ | ||
func(s *KafkaSourceStatus, c fuzz.Continue) { | ||
c.FuzzNoCustom(s) // fuzz the status object | ||
|
||
// Clear the random fuzzed condition | ||
s.Status.SetConditions(nil) | ||
|
||
// Fuzz the known conditions except their type value | ||
s.InitializeConditions() | ||
pkgfuzzer.FuzzConditions(&s.Status, c) | ||
}, | ||
} | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Copyright 2020 The Knative Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
pkgfuzzer "knative.dev/pkg/apis/testing/fuzzer" | ||
"knative.dev/pkg/apis/testing/roundtrip" | ||
) | ||
|
||
func TestSourcesRoundTripTypesToJSON(t *testing.T) { | ||
scheme := runtime.NewScheme() | ||
utilruntime.Must(AddToScheme(scheme)) | ||
|
||
fuzzerFuncs := fuzzer.MergeFuzzerFuncs( | ||
pkgfuzzer.Funcs, | ||
FuzzerFuncs, | ||
) | ||
roundtrip.ExternalTypesViaJSON(t, scheme, fuzzerFuncs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.