Skip to content

Commit

Permalink
add stub rpaas @ fakeserver
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarreira authored and wpjunior committed May 16, 2022
1 parent fef3418 commit 9196e4d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/web/target/fake-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import (
"context"
"net/http"

"github.com/tsuru/rpaas-operator/api/v1alpha1"
"github.com/tsuru/rpaas-operator/internal/pkg/rpaas"
extensionsruntime "github.com/tsuru/rpaas-operator/pkg/runtime"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand All @@ -22,7 +25,7 @@ func (f *fakeServerFactory) Manager(ctx context.Context, header http.Header) (rp
func NewFakeServerFactory() (Factory, error) {

scheme := extensionsruntime.NewScheme()
k8sClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects().Build()
k8sClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(fakeRuntimeObjects()...).Build()

manager, err := rpaas.NewK8S(nil, k8sClient, "", "")
if err != nil {
Expand All @@ -35,3 +38,20 @@ func NewFakeServerFactory() (Factory, error) {
func NewFakeFactory(manager rpaas.RpaasManager) Factory {
return &fakeServerFactory{manager: manager}
}

func fakeRuntimeObjects() []runtime.Object {
return []runtime.Object{
&v1alpha1.RpaasPlan{
ObjectMeta: metav1.ObjectMeta{
Name: "my-plan",
Namespace: "rpaasv2",
},
},
&v1alpha1.RpaasInstance{
ObjectMeta: metav1.ObjectMeta{
Name: "my-rpaas",
Namespace: "rpaasv2",
},
},
}
}

0 comments on commit 9196e4d

Please sign in to comment.