fix(test): no check empty resources

Signed-off-by: Manuel Alonso <434575+manute@users.noreply.github.com>
pull/31578/head
Manuel Alonso 1 week ago
parent 52235cc0bf
commit 0357e8d0f7
No known key found for this signature in database
GPG Key ID: 9315A3EFCBD4D56A

@ -190,10 +190,6 @@ func (i *Install) installCRDs(crds []chart.CRD) error {
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
if _, err := i.cfg.KubeClient.Create(
res,

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

Loading…
Cancel
Save