-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added simple kuttl and unit test to make sure the CRD can be applied
Signed-off-by: Florian Bacher <[email protected]>
- Loading branch information
Showing
4 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
operator/controllers/lifecycle/keptnappcreationrequest/controller_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package keptnappcreationrequest | ||
|
||
import ( | ||
"context" | ||
"github.com/go-logr/logr" | ||
klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" | ||
"github.com/stretchr/testify/require" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
controllerruntime "sigs.k8s.io/controller-runtime" | ||
k8sfake "sigs.k8s.io/controller-runtime/pkg/client/fake" | ||
"testing" | ||
) | ||
|
||
func TestKeptnAppCreationRequestReconciler_Reconcile(t *testing.T) { | ||
fakeClient := k8sfake.NewClientBuilder().WithObjects().Build() | ||
|
||
err := klcv1alpha3.AddToScheme(fakeClient.Scheme()) | ||
require.Nil(t, err) | ||
|
||
kacr := &klcv1alpha3.KeptnAppCreationRequest{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "my-kacr", | ||
Namespace: "my-namespace", | ||
}, | ||
Spec: klcv1alpha3.KeptnAppCreationRequestSpec{ | ||
AppName: "my-app", | ||
}, | ||
} | ||
|
||
err = fakeClient.Create(context.TODO(), kacr) | ||
require.Nil(t, err) | ||
|
||
r := &KeptnAppCreationRequestReconciler{ | ||
Client: fakeClient, | ||
Scheme: fakeClient.Scheme(), | ||
Log: logr.Logger{}, | ||
} | ||
|
||
_, err = r.Reconcile(context.Background(), controllerruntime.Request{ | ||
NamespacedName: types.NamespacedName{ | ||
Namespace: kacr.Namespace, | ||
Name: kacr.Name, | ||
}, | ||
}) | ||
|
||
require.Nil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: lifecycle.keptn.sh/v1alpha3 | ||
kind: KeptnAppCreationRequest | ||
metadata: | ||
name: my-kacr | ||
spec: | ||
appName: my-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: lifecycle.keptn.sh/v1alpha3 | ||
kind: KeptnAppCreationRequest | ||
metadata: | ||
name: my-kacr | ||
spec: | ||
appName: my-app |