fix(test): no check empty resources

Signed-off-by: Manuel Alonso <434575+manute@users.noreply.github.com>
(cherry picked from commit 0357e8d0f7)
pull/31940/head
Manuel Alonso 9 months ago committed by Scott Rigby
parent fdadff59eb
commit f451967ab5
No known key found for this signature in database
GPG Key ID: C7C6FBB5B91C1155

@ -191,10 +191,6 @@ func (i *Install) installCRDs(crds []chart.CRD) error {
return fmt.Errorf("failed to install CRD %s: %w", obj.Name, err) return fmt.Errorf("failed to install CRD %s: %w", obj.Name, err)
} }
if len(res) == 0 {
return fmt.Errorf("failed to install CRD %s: resources are empty", obj.Name)
}
// Send them to Kube // Send them to Kube
if _, err := i.cfg.KubeClient.Create( if _, err := i.cfg.KubeClient.Create(
res, res,

@ -1211,28 +1211,32 @@ func TestInstallRelease_WaitOptionsPassedDownstream(t *testing.T) {
func TestInstallCRDs_CheckNilErrors(t *testing.T) { func TestInstallCRDs_CheckNilErrors(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
input []chart.CRD input []chart.CRD
expectedErr bool
}{ }{
{ {
name: "only one crd with file nil", name: "only one crd with file nil",
input: []chart.CRD{ input: []chart.CRD{
{Name: "one", File: nil}, {Name: "one", File: nil},
}, },
expectedErr: true,
}, },
{ {
name: "only one crd with its file data nil", name: "only one crd with its file data nil",
input: []chart.CRD{ input: []chart.CRD{
{Name: "one", File: &common.File{Name: "crds/foo.yaml", Data: nil}}, {Name: "one", File: &common.File{Name: "crds/foo.yaml", Data: nil}},
}, },
expectedErr: false,
}, },
{ {
name: "at least a crd with its file data nil", name: "at least a crd with its file data nil",
input: []chart.CRD{ input: []chart.CRD{
{Name: "one", File: &common.File{Name: "crds/foo.yaml", Data: []byte("data")}}, {Name: "one", File: &common.File{Name: "crds/foo.yaml", Data: []byte("data")}},
{Name: "two", File: &common.File{Name: "crds/foo.yaml", Data: nil}}, {Name: "two", File: &common.File{Name: "crds/foo2.yaml", Data: nil}},
{Name: "three", File: &common.File{Name: "crds/foo.yaml", Data: []byte("data")}}, {Name: "three", File: &common.File{Name: "crds/foo3.yaml", Data: []byte("data")}},
}, },
expectedErr: false,
}, },
} }
@ -1241,8 +1245,8 @@ func TestInstallCRDs_CheckNilErrors(t *testing.T) {
instAction := installAction(t) instAction := installAction(t)
err := instAction.installCRDs(tt.input) err := instAction.installCRDs(tt.input)
if err == nil { if tt.expectedErr && err == nil {
t.Errorf("got error expected nil") t.Errorf("got error %v expected nil", err)
} }
}) })
} }

Loading…
Cancel
Save