ricardozanini commented on code in PR #322:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/322#discussion_r1461991458


##########
controllers/profiles/common/object_creators_test.go:
##########
@@ -169,3 +169,171 @@ func TestMergePodSpec_OverrideContainers(t *testing.T) {
        assert.Equal(t, int32(8080), flowContainer.Ports[0].ContainerPort)
        assert.Empty(t, flowContainer.Env)
 }
+
+func TestMergePodSpec_WithPostgreSQL_and_JDBC_URL_field(t *testing.T) {
+       workflow := test.GetBaseSonataFlow(t.Name())
+       workflow.Spec = v1alpha08.SonataFlowSpec{
+               PodTemplate: v1alpha08.PodTemplateSpec{
+                       Container: v1alpha08.ContainerSpec{
+                               // this one we can override
+                               Image: "quay.io/example/my-workflow:1.0.0",
+                               Ports: []corev1.ContainerPort{
+                                       // let's override a immutable attribute
+                                       {Name: utils.HttpScheme, ContainerPort: 
9090},
+                               },
+                               Env: []corev1.EnvVar{
+                                       // We should be able to override this 
too
+                                       {Name: "ENV1", Value: "VALUE_CUSTOM"},
+                               },
+                               VolumeMounts: []corev1.VolumeMount{
+                                       {Name: "myvolume", ReadOnly: true, 
MountPath: "/tmp/any/path"},
+                               },
+                       },
+                       PodSpec: v1alpha08.PodSpec{
+                               ServiceAccountName: "superuser",
+                               Containers: []corev1.Container{
+                                       {
+                                               Name: "sidecar",
+                                       },
+                               },
+                               Volumes: []corev1.Volume{
+                                       {
+                                               Name: "myvolume",
+                                               VolumeSource: 
corev1.VolumeSource{
+                                                       ConfigMap: 
&corev1.ConfigMapVolumeSource{
+                                                               
LocalObjectReference: corev1.LocalObjectReference{Name: "customproperties"},
+                                                       },
+                                               },
+                                       },
+                               },
+                       },
+               },
+               Persistence: &v1alpha08.PersistenceOptions{
+                       PostgreSql: &v1alpha08.PersistencePostgreSql{
+                               SecretRef: 
v1alpha08.PostgreSqlSecretOptions{Name: "test"},
+                               JdbcUrl:   
"jdbc:postgresql://host:port/database?currentSchema=workflow",
+                       },
+               },
+       }
+
+       object, err := DeploymentCreator(workflow)
+       assert.NoError(t, err)
+
+       deployment := object.(*appsv1.Deployment)
+       expectedEnvVars := []corev1.EnvVar{
+               {
+                       Name:  "ENV1",
+                       Value: "VALUE_CUSTOM",
+               },
+               {
+                       Name:  "QUARKUS_DATASOURCE_USERNAME",
+                       Value: "",
+                       ValueFrom: &corev1.EnvVarSource{
+                               SecretKeyRef: &corev1.SecretKeySelector{
+                                       LocalObjectReference: 
corev1.LocalObjectReference{Name: "test"}, Key: "POSTGRESQL_USER",
+                               },
+                       },
+               },
+               {
+                       Name:  "QUARKUS_DATASOURCE_PASSWORD",
+                       Value: "",
+                       ValueFrom: &corev1.EnvVarSource{
+                               SecretKeyRef: &corev1.SecretKeySelector{
+                                       LocalObjectReference: 
corev1.LocalObjectReference{Name: "test"}, Key: "POSTGRESQL_PASSWORD",
+                               },
+                       },
+               },
+               {
+                       Name:  "QUARKUS_DATASOURCE_DB_KIND",
+                       Value: "postgresql",
+               },
+               {
+                       Name:  "QUARKUS_DATASOURCE_JDBC_URL",
+                       Value: 
"jdbc:postgresql://host:port/database?currentSchema=workflow",
+               },
+       }
+       assert.Len(t, deployment.Spec.Template.Spec.Containers, 2)
+       assert.Equal(t, "superuser", 
deployment.Spec.Template.Spec.ServiceAccountName)
+       assert.Len(t, deployment.Spec.Template.Spec.Volumes, 1)
+       flowContainer, _ := 
kubeutil.GetContainerByName(v1alpha08.DefaultContainerName, 
&deployment.Spec.Template.Spec)
+       assert.Equal(t, "quay.io/example/my-workflow:1.0.0", 
flowContainer.Image)
+       assert.Equal(t, int32(8080), flowContainer.Ports[0].ContainerPort)
+       assert.Equal(t, expectedEnvVars, flowContainer.Env)
+       assert.Len(t, flowContainer.VolumeMounts, 1)
+}
+
+var (
+       postgreSQLPort = 5432

Review Comment:
   I'd keep it within the test scope then.



-- 
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]

Reply via email to