|
| 1 | +/* |
| 2 | +Copyright Red Hat, Inc. |
| 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 v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + "testing" |
| 21 | + |
| 22 | + "github.com/stretchr/testify/require" |
| 23 | +) |
| 24 | + |
| 25 | +func TestOpenAPIModelName(t *testing.T) { |
| 26 | + tests := []struct { |
| 27 | + name string |
| 28 | + typeFunc func() string |
| 29 | + expected string |
| 30 | + }{ |
| 31 | + { |
| 32 | + name: "APIResourceReference", |
| 33 | + typeFunc: func() string { return APIResourceReference{}.OpenAPIModelName() }, |
| 34 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.APIResourceReference", |
| 35 | + }, |
| 36 | + { |
| 37 | + name: "APIServiceDefinitions", |
| 38 | + typeFunc: func() string { return APIServiceDefinitions{}.OpenAPIModelName() }, |
| 39 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.APIServiceDefinitions", |
| 40 | + }, |
| 41 | + { |
| 42 | + name: "APIServiceDescription", |
| 43 | + typeFunc: func() string { return APIServiceDescription{}.OpenAPIModelName() }, |
| 44 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.APIServiceDescription", |
| 45 | + }, |
| 46 | + { |
| 47 | + name: "ActionDescriptor", |
| 48 | + typeFunc: func() string { return ActionDescriptor{}.OpenAPIModelName() }, |
| 49 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ActionDescriptor", |
| 50 | + }, |
| 51 | + { |
| 52 | + name: "AppLink", |
| 53 | + typeFunc: func() string { return AppLink{}.OpenAPIModelName() }, |
| 54 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.AppLink", |
| 55 | + }, |
| 56 | + { |
| 57 | + name: "CRDDescription", |
| 58 | + typeFunc: func() string { return CRDDescription{}.OpenAPIModelName() }, |
| 59 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.CRDDescription", |
| 60 | + }, |
| 61 | + { |
| 62 | + name: "CleanupSpec", |
| 63 | + typeFunc: func() string { return CleanupSpec{}.OpenAPIModelName() }, |
| 64 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.CleanupSpec", |
| 65 | + }, |
| 66 | + { |
| 67 | + name: "CleanupStatus", |
| 68 | + typeFunc: func() string { return CleanupStatus{}.OpenAPIModelName() }, |
| 69 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.CleanupStatus", |
| 70 | + }, |
| 71 | + { |
| 72 | + name: "ClusterServiceVersionCondition", |
| 73 | + typeFunc: func() string { return ClusterServiceVersionCondition{}.OpenAPIModelName() }, |
| 74 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionCondition", |
| 75 | + }, |
| 76 | + { |
| 77 | + name: "ClusterServiceVersionSpec", |
| 78 | + typeFunc: func() string { return ClusterServiceVersionSpec{}.OpenAPIModelName() }, |
| 79 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionSpec", |
| 80 | + }, |
| 81 | + { |
| 82 | + name: "ClusterServiceVersionStatus", |
| 83 | + typeFunc: func() string { return ClusterServiceVersionStatus{}.OpenAPIModelName() }, |
| 84 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionStatus", |
| 85 | + }, |
| 86 | + { |
| 87 | + name: "CustomResourceDefinitions", |
| 88 | + typeFunc: func() string { return CustomResourceDefinitions{}.OpenAPIModelName() }, |
| 89 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.CustomResourceDefinitions", |
| 90 | + }, |
| 91 | + { |
| 92 | + name: "DependentStatus", |
| 93 | + typeFunc: func() string { return DependentStatus{}.OpenAPIModelName() }, |
| 94 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.DependentStatus", |
| 95 | + }, |
| 96 | + { |
| 97 | + name: "Icon", |
| 98 | + typeFunc: func() string { return Icon{}.OpenAPIModelName() }, |
| 99 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.Icon", |
| 100 | + }, |
| 101 | + { |
| 102 | + name: "InstallMode", |
| 103 | + typeFunc: func() string { return InstallMode{}.OpenAPIModelName() }, |
| 104 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.InstallMode", |
| 105 | + }, |
| 106 | + { |
| 107 | + name: "Maintainer", |
| 108 | + typeFunc: func() string { return Maintainer{}.OpenAPIModelName() }, |
| 109 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.Maintainer", |
| 110 | + }, |
| 111 | + { |
| 112 | + name: "NamedInstallStrategy", |
| 113 | + typeFunc: func() string { return NamedInstallStrategy{}.OpenAPIModelName() }, |
| 114 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.NamedInstallStrategy", |
| 115 | + }, |
| 116 | + { |
| 117 | + name: "RelatedImage", |
| 118 | + typeFunc: func() string { return RelatedImage{}.OpenAPIModelName() }, |
| 119 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.RelatedImage", |
| 120 | + }, |
| 121 | + { |
| 122 | + name: "RequirementStatus", |
| 123 | + typeFunc: func() string { return RequirementStatus{}.OpenAPIModelName() }, |
| 124 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.RequirementStatus", |
| 125 | + }, |
| 126 | + { |
| 127 | + name: "ResourceInstance", |
| 128 | + typeFunc: func() string { return ResourceInstance{}.OpenAPIModelName() }, |
| 129 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ResourceInstance", |
| 130 | + }, |
| 131 | + { |
| 132 | + name: "ResourceList", |
| 133 | + typeFunc: func() string { return ResourceList{}.OpenAPIModelName() }, |
| 134 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ResourceList", |
| 135 | + }, |
| 136 | + { |
| 137 | + name: "SpecDescriptor", |
| 138 | + typeFunc: func() string { return SpecDescriptor{}.OpenAPIModelName() }, |
| 139 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.SpecDescriptor", |
| 140 | + }, |
| 141 | + { |
| 142 | + name: "StatusDescriptor", |
| 143 | + typeFunc: func() string { return StatusDescriptor{}.OpenAPIModelName() }, |
| 144 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.StatusDescriptor", |
| 145 | + }, |
| 146 | + { |
| 147 | + name: "StrategyDeploymentPermissions", |
| 148 | + typeFunc: func() string { return StrategyDeploymentPermissions{}.OpenAPIModelName() }, |
| 149 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDeploymentPermissions", |
| 150 | + }, |
| 151 | + { |
| 152 | + name: "StrategyDeploymentSpec", |
| 153 | + typeFunc: func() string { return StrategyDeploymentSpec{}.OpenAPIModelName() }, |
| 154 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDeploymentSpec", |
| 155 | + }, |
| 156 | + { |
| 157 | + name: "StrategyDetailsDeployment", |
| 158 | + typeFunc: func() string { return StrategyDetailsDeployment{}.OpenAPIModelName() }, |
| 159 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDetailsDeployment", |
| 160 | + }, |
| 161 | + { |
| 162 | + name: "WebhookDescription", |
| 163 | + typeFunc: func() string { return WebhookDescription{}.OpenAPIModelName() }, |
| 164 | + expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.WebhookDescription", |
| 165 | + }, |
| 166 | + } |
| 167 | + |
| 168 | + for _, tt := range tests { |
| 169 | + t.Run(tt.name, func(t *testing.T) { |
| 170 | + require.Equal(t, tt.expected, tt.typeFunc()) |
| 171 | + }) |
| 172 | + } |
| 173 | +} |
0 commit comments