Skip to content

Commit

Permalink
Extra test for AllCRDs().
Browse files Browse the repository at this point in the history
  • Loading branch information
fasaxc committed Oct 2, 2024
1 parent 35ac48b commit 90259dd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions libcalico-go/config/crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package config

import (
"fmt"
"testing"

v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -43,3 +44,26 @@ func ExampleLoadCRD() {
fmt.Println(crd.GetName())
// Output: felixconfigurations.crd.projectcalico.org
}

func TestAllCRDs(t *testing.T) {
crds, err := AllCRDs()
if err != nil {
t.Fatal(err)
}
const expectedCRDs = 20
if len(crds) < expectedCRDs {
t.Fatal("Expected at least", expectedCRDs, "CRDs, got", len(crds))
}
// Basic sanity check that we didn't load anything we didn't expect.
for _, crd := range crds {
if crd.GetName() == "" {
t.Fatal("CRD had no name?")
}
if crd.Spec.Group == "" {
t.Fatal("CRD had no group?")
}
if len(crd.Spec.Versions) == 0 {
t.Fatal("CRD had no versions?")
}
}
}

0 comments on commit 90259dd

Please sign in to comment.