Skip to content

Commit c9655e2

Browse files
committed
test(cozystack-api): guard instancetype/instanceprofile provider GVRs
instancetype/instanceprofile replaced the static vm-instance enum with live dropdowns sourced from instancetype.kubevirt.io. A wrong group/version would make those dropdowns silently empty in every cluster (List tolerates the error) — the failure mode the appkind GVR guard already catches. Pin both GVRs to the served API. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent f92b49e commit c9655e2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎pkg/registry/core/option/providers_test.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ func TestAppKindProviderUsesApplicationDefinitionCRDGroup(t *testing.T) {
154154
}
155155
}
156156

157+
func TestInstanceProviderGVRsMatchKubevirtInstancetypeAPI(t *testing.T) {
158+
// instancetype/instanceprofile replaced the static vm-instance enum with
159+
// live dropdowns; a wrong group/version here makes the dropdown silently
160+
// empty in every cluster (List tolerates the error), the same failure mode
161+
// the appkind guard above catches. Pin both GVRs to the served API.
162+
if gvrInstancetype.Group != "instancetype.kubevirt.io" || gvrInstancetype.Version != "v1beta1" ||
163+
gvrInstancetype.Resource != "virtualmachineclusterinstancetypes" {
164+
t.Errorf("instancetype provider GVR = %v, want instancetype.kubevirt.io/v1beta1 virtualmachineclusterinstancetypes", gvrInstancetype)
165+
}
166+
if gvrPreference.Group != "instancetype.kubevirt.io" || gvrPreference.Version != "v1beta1" ||
167+
gvrPreference.Resource != "virtualmachineclusterpreferences" {
168+
t.Errorf("instanceprofile provider GVR = %v, want instancetype.kubevirt.io/v1beta1 virtualmachineclusterpreferences", gvrPreference)
169+
}
170+
}
171+
157172
func TestRESTListExposesNewSources(t *testing.T) {
158173
dyn := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(runtime.NewScheme(), listKinds())
159174
r := NewREST(DefaultProviders(dyn))

0 commit comments

Comments
 (0)