Skip to content

Commit

Permalink
KafkaSource/Sink: Adding interface implementation test
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
  • Loading branch information
matzew committed Sep 23, 2024
1 parent 545216c commit 285398a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
39 changes: 39 additions & 0 deletions control-plane/pkg/apis/eventing/v1alpha1/implements_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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"

"knative.dev/pkg/apis/duck"
duckv1 "knative.dev/pkg/apis/duck/v1"
)

func TestTypesImplements(t *testing.T) {
testCases := []struct {
instance interface{}
iface duck.Implementable
}{
{instance: &KafkaSink{}, iface: &duckv1.Conditions{}},
{instance: &KafkaSink{}, iface: &duckv1.Addressable{}},
}
for _, tc := range testCases {
if err := duck.VerifyType(tc.instance, tc.iface); err != nil {
t.Error(err)
}
}
}
39 changes: 39 additions & 0 deletions control-plane/pkg/apis/sources/v1beta1/implements_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2020 The Knative Authors.

Check failure on line 2 in control-plane/pkg/apis/sources/v1beta1/implements_test.go

View workflow job for this annotation

GitHub Actions / style / Golang / Boilerplate Check (go)

[Go headers] reported by reviewdog 🐶 found mismatched boilerplate lines: Raw Output: control-plane/pkg/apis/sources/v1beta1/implements_test.go:2: found mismatched boilerplate lines: {[]string}[0]: -: " * Copyright 2024 The Knative Authors" +: "Copyright 2024 The Knative Authors." {[]string}[1]: -: " *" +: "" {[]string}[2]: -: ` * Licensed under the Apache License, Version 2.0 (the "License");` +: `Licensed under the Apache License, Version 2.0 (the "License");` {[]string}[3]: -: " * you may not use this file except in compliance with the License." +: "you may not use this file except in compliance with the License." {[]string}[4]: -: " * You may obtain a copy of the License at" +: "You may obtain a copy of the License at" {[]string}[5]: -: " *" +: "" {[]string}[6]: -: " * http://www.apache.org/licenses/LICENSE-2.0" +: " http://www.apache.org/licenses/LICENSE-2.0" {[]string}[7]: -: " *" +: "" {[]string}[8]: -: " * Unless required by applicable law or agreed to in writing, software" +: "Unless required by applicable law or agreed to in writing, software" {[]string}[9]: -: ` * distributed under the License is distributed on an "AS IS" BASIS,` +: `distributed under the License is distributed on an "AS IS" BASIS,` {[]string}[10]: -: " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." +: "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." {[]string}[11]: -: " * See the License for the specific language governing permissions and" +: "See the License for the specific language governing permissions and" {[]string}[12]: -: " * limitations under the License." +: "limitations under the License." {[]string}[13]: -: " */" +: "*/"
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"

"knative.dev/pkg/apis/duck"
duckv1 "knative.dev/pkg/apis/duck/v1"
)

func TestTypesImplements(t *testing.T) {
testCases := []struct {
instance interface{}
iface duck.Implementable
}{
{instance: &KafkaSource{}, iface: &duckv1.Conditions{}},
{instance: &KafkaSource{}, iface: &duckv1.Source{}},
}
for _, tc := range testCases {
if err := duck.VerifyType(tc.instance, tc.iface); err != nil {
t.Error(err)
}
}
}

0 comments on commit 285398a

Please sign in to comment.