You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "rgolangh (via GitHub)" <gi...@apache.org> on 2024/07/25 13:45:18 UTC

[PR] Add tests for workflowproj/operator.go [incubator-kie-kogito-serverless-operator]

rgolangh opened a new pull request, #508:
URL: https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/508

   Signed-off-by: Roy Golan <rg...@redhat.com>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] Add tests for workflowproj/operator.go [incubator-kie-kogito-serverless-operator]

Posted by "rgolangh (via GitHub)" <gi...@apache.org>.
rgolangh commented on PR #508:
URL: https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/508#issuecomment-2250988032

   > @rgolangh looks like make generate-all is required here maybe?
   
   yes forgot that, thanks. Fixing


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] Add tests for workflowproj/operator.go [incubator-kie-kogito-serverless-operator]

Posted by "wmedvede (via GitHub)" <gi...@apache.org>.
wmedvede commented on PR #508:
URL: https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/508#issuecomment-2250528312

   @rgolangh looks like make generate-all is required here maybe?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] Add tests for workflowproj/operator.go [incubator-kie-kogito-serverless-operator]

Posted by "ricardozanini (via GitHub)" <gi...@apache.org>.
ricardozanini merged PR #508:
URL: https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/508


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] Add tests for workflowproj/operator.go [incubator-kie-kogito-serverless-operator]

Posted by "rgolangh (via GitHub)" <gi...@apache.org>.
rgolangh commented on PR #508:
URL: https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/508#issuecomment-2250363259

   @wmedvede more coverage for the lables work


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] Add tests for workflowproj/operator.go [incubator-kie-kogito-serverless-operator]

Posted by "ricardozanini (via GitHub)" <gi...@apache.org>.
ricardozanini commented on PR #508:
URL: https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/508#issuecomment-2277864717

   @rgolangh cau you please rebase?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] Add tests for workflowproj/operator.go [incubator-kie-kogito-serverless-operator]

Posted by "ricardozanini (via GitHub)" <gi...@apache.org>.
ricardozanini commented on code in PR #508:
URL: https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/508#discussion_r1699073473


##########
workflowproj/operator_test.go:
##########
@@ -0,0 +1,321 @@
+// Copyright 2024 Apache Software Foundation (ASF)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package workflowproj
+
+import (
+	"testing"
+
+	operatorapi "github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
+	"github.com/stretchr/testify/assert"
+	corev1 "k8s.io/api/core/v1"
+	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+)
+
+func TestCreateNewManagedPropsConfigMap(t *testing.T) {
+	type args struct {
+		workflow   *operatorapi.SonataFlow
+		properties string
+	}
+	tests := []struct {
+		name string
+		args args
+		want map[string]string
+	}{
+		{
+			"when workflow has labels",
+			args{workflow: &operatorapi.SonataFlow{ObjectMeta: v1.ObjectMeta{
+				Name: t.Name(),
+				Labels: map[string]string{
+					"app.kubernetes.io/name":       t.Name(),
+					"app.kubernetes.io/component":  "serverless-workflow",
+					"app.kubernetes.io/managed-by": "sonataflow-operator",
+					"app.kubernetes.io/part-of":    "someplatform",
+				}}}},
+
+			map[string]string{
+				"app.kubernetes.io/name":       t.Name(),
+				"app.kubernetes.io/component":  "serverless-workflow",
+				"app.kubernetes.io/managed-by": "sonataflow-operator",
+				"app.kubernetes.io/part-of":    "someplatform",
+				"sonataflow.org/workflow-app":  t.Name(),
+			},
+		},
+		{
+			"when the workflow has no labels",
+			args{workflow: &operatorapi.SonataFlow{ObjectMeta: v1.ObjectMeta{
+				Name:   t.Name(),
+				Labels: map[string]string{}}}},
+
+			map[string]string{
+				"app.kubernetes.io/name":       t.Name(),
+				"app.kubernetes.io/component":  "serverless-workflow",
+				"app.kubernetes.io/managed-by": "sonataflow-operator",
+				// if the workflow is missing a platform then the managed properties won't have them
+				//"app.kubernetes.io/part-of":   "someplatform",
+				"sonataflow.org/workflow-app": t.Name(),
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			assert.Equalf(t, tt.want, CreateNewManagedPropsConfigMap(
+				tt.args.workflow, tt.args.properties).GetLabels(),
+				"CreateNewManagedPropsConfigMap(%v, %v)", tt.args.workflow, tt.args.properties)
+		})
+	}
+}
+
+func TestCreateNewUserPropsConfigMap(t *testing.T) {
+	type args struct {
+		workflow *operatorapi.SonataFlow
+	}
+	tests := []struct {
+		name string
+		args args
+		want *corev1.ConfigMap
+	}{
+		//TODO add tests

Review Comment:
   missing tests?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org