camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject [camel-k] 08/14: Added tests about traits configuration
Date Mon, 08 Oct 2018 14:19:48 GMT
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 0d08f7298b9fee7283edb65611c50568d6d5971a
Author: nferraro <ni.ferraro@gmail.com>
AuthorDate: Thu Oct 4 23:19:03 2018 +0200

    Added tests about traits configuration
---
 pkg/trait/trait_test.go | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index 9ffea3a..8427068 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -64,6 +64,40 @@ func TestOpenshiftTraitsWithWeb(t *testing.T) {
 	}))
 }
 
+func TestOpenshiftTraitsWithWebAndConfig(t *testing.T) {
+	env := createTestEnv(v1alpha1.IntegrationPlatformClusterOpenShift, "camel:core", "camel:undertow")
+	env.Integration.Spec.Traits = make(map[string]v1alpha1.IntegrationTraitSpec)
+	env.Integration.Spec.Traits["service"] = v1alpha1.IntegrationTraitSpec{
+		Configuration: map[string]string{
+			"port": "7071",
+		},
+	}
+	res := processTestEnv(t, env)
+	assert.Contains(t, env.ExecutedCustomizers, id("service"))
+	assert.Contains(t, env.ExecutedCustomizers, id("route"))
+	assert.NotNil(t, res.GetService(func(svc *corev1.Service) bool {
+		return svc.Name == "test" && svc.Spec.Ports[0].TargetPort.IntVal == int32(7071)
+	}))
+}
+
+func TestOpenshiftTraitsWithWebAndDisabledTrait(t *testing.T) {
+	falseBoolean := false
+	env := createTestEnv(v1alpha1.IntegrationPlatformClusterOpenShift, "camel:core", "camel:undertow")
+	env.Integration.Spec.Traits = make(map[string]v1alpha1.IntegrationTraitSpec)
+	env.Integration.Spec.Traits["service"] = v1alpha1.IntegrationTraitSpec{
+		Configuration: map[string]string{
+			"port": "7071",
+		},
+		Enabled: &falseBoolean,
+	}
+	res := processTestEnv(t, env)
+	assert.NotContains(t, env.ExecutedCustomizers, id("service"))
+	assert.NotContains(t, env.ExecutedCustomizers, id("route")) // No route without service
+	assert.Nil(t, res.GetService(func(svc *corev1.Service) bool {
+		return true
+	}))
+}
+
 func TestKubernetesTraits(t *testing.T) {
 	env := createTestEnv(v1alpha1.IntegrationPlatformClusterKubernetes, "camel:core")
 	res := processTestEnv(t, env)


Mime
View raw message