Files
open-cluster-management/pkg/controllers/placement/controller_test.go
Yang Le 45a1ebb053 add missing files
Signed-off-by: Yang Le <yangle@redhat.com>
2021-05-06 15:59:42 +08:00

45 lines
1.3 KiB
Go

package placement
import (
"context"
"testing"
"time"
"k8s.io/apimachinery/pkg/runtime"
clienttesting "k8s.io/client-go/testing"
clusterfake "github.com/open-cluster-management/api/client/cluster/clientset/versioned/fake"
clusterinformers "github.com/open-cluster-management/api/client/cluster/informers/externalversions"
testinghelpers "github.com/open-cluster-management/placement/pkg/helpers/testing"
)
func TestSync(t *testing.T) {
cases := []struct {
name string
queueKey string
initObjs []runtime.Object
validateActions func(t *testing.T, hubActions, agentActions []clienttesting.Action)
}{}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
clusterClient := clusterfake.NewSimpleClientset(c.initObjs...)
clusterInformerFactory := clusterinformers.NewSharedInformerFactory(clusterClient, time.Minute*10)
clusterStore := clusterInformerFactory.Cluster().V1().ManagedClusters().Informer().GetStore()
for _, cluster := range c.initObjs {
clusterStore.Add(cluster)
}
ctrl := placementController{
clusterLister: clusterInformerFactory.Cluster().V1().ManagedClusters().Lister(),
}
syncErr := ctrl.sync(context.TODO(), testinghelpers.NewFakeSyncContext(t, c.queueKey))
if syncErr != nil {
t.Errorf("unexpected err: %v", syncErr)
}
//c.validateActions(t, nil)
})
}
}