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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
