63 lines
2.0 KiB
Go
63 lines
2.0 KiB
Go
//
|
|
// Copyright (c) 2019-2024 Red Hat, Inc.
|
|
// This program and the accompanying materials are made
|
|
// available under the terms of the Eclipse Public License 2.0
|
|
// which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
//
|
|
// SPDX-License-Identifier: EPL-2.0
|
|
//
|
|
// Contributors:
|
|
// Red Hat, Inc. - initial API and implementation
|
|
//
|
|
|
|
package pluginregistry
|
|
|
|
import (
|
|
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
|
|
chev2 "github.com/eclipse-che/che-operator/api/v2"
|
|
"github.com/eclipse-che/che-operator/pkg/common/test"
|
|
"github.com/stretchr/testify/assert"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/utils/pointer"
|
|
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
corev1 "k8s.io/api/core/v1"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
"k8s.io/apimachinery/pkg/types"
|
|
|
|
"testing"
|
|
)
|
|
|
|
func TestPluginRegistryReconcile(t *testing.T) {
|
|
infrastructure.InitializeForTesting(infrastructure.OpenShiftv4)
|
|
|
|
ctx := test.GetDeployContext(
|
|
&chev2.CheCluster{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "eclipse-che",
|
|
Namespace: "eclipse-che",
|
|
},
|
|
Spec: chev2.CheClusterSpec{
|
|
Components: chev2.CheClusterComponents{
|
|
PluginRegistry: chev2.PluginRegistry{
|
|
OpenVSXURL: pointer.String(""),
|
|
},
|
|
},
|
|
},
|
|
Status: chev2.CheClusterStatus{
|
|
CheURL: "https://che-host",
|
|
},
|
|
},
|
|
[]runtime.Object{})
|
|
|
|
pluginregistry := NewPluginRegistryReconciler()
|
|
_, done, err := pluginregistry.Reconcile(ctx)
|
|
assert.True(t, done)
|
|
assert.Nil(t, err)
|
|
|
|
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "plugin-registry", Namespace: "eclipse-che"}, &corev1.Service{}))
|
|
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "plugin-registry", Namespace: "eclipse-che"}, &corev1.ConfigMap{}))
|
|
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "plugin-registry", Namespace: "eclipse-che"}, &appsv1.Deployment{}))
|
|
assert.NotEmpty(t, ctx.CheCluster.Status.PluginRegistryURL)
|
|
}
|