diff --git a/pkg/apis/serving/v1alpha1/domainmapping_lifecycle_test.go b/pkg/apis/serving/v1alpha1/domainmapping_lifecycle_test.go new file mode 100644 index 000000000000..bd3def6c91a1 --- /dev/null +++ b/pkg/apis/serving/v1alpha1/domainmapping_lifecycle_test.go @@ -0,0 +1,65 @@ +/* +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/runtime/schema" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +func TestDomainMappingDuckTypes(t *testing.T) { + tests := []struct { + name string + t duck.Implementable + }{{ + name: "conditions", + t: &duckv1.Conditions{}, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + err := duck.VerifyType(&DomainMapping{}, test.t) + if err != nil { + t.Errorf("VerifyType(DomainMapping, %T) = %v", test.t, err) + } + }) + } +} + +func TestDomainMappingGetConditionSet(t *testing.T) { + r := &DomainMapping{} + + if got, want := r.GetConditionSet().GetTopLevelConditionType(), apis.ConditionReady; got != want { + t.Errorf("GetTopLevelCondition=%v, want=%v", got, want) + } +} + +func TestDomainMappingGetGroupVersionKind(t *testing.T) { + r := &DomainMapping{} + want := schema.GroupVersionKind{ + Group: "serving.knative.dev", + Version: "v1alpha1", + Kind: "DomainMapping", + } + if got := r.GetGroupVersionKind(); got != want { + t.Errorf("got: %v, want: %v", got, want) + } +} diff --git a/pkg/apis/serving/v1alpha1/domainmapping_types_test.go b/pkg/apis/serving/v1alpha1/domainmapping_types_test.go new file mode 100644 index 000000000000..8e75105e1c23 --- /dev/null +++ b/pkg/apis/serving/v1alpha1/domainmapping_types_test.go @@ -0,0 +1,37 @@ +/* +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" + + "github.com/google/go-cmp/cmp" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +func TestDomainMappingGetStatus(t *testing.T) { + status := &duckv1.Status{} + config := DomainMapping{ + Status: DomainMappingStatus{ + Status: *status, + }, + } + + if !cmp.Equal(config.GetStatus(), status) { + t.Errorf("GetStatus did not retrieve status. Got=%v Want=%v", config.GetStatus(), status) + } +}