This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
     new 9488068b5 fix(e2e): resolve Camel version from catalog for test local
9488068b5 is described below

commit 9488068b5d3c354a1a55200167aaa4c113494b3f
Author: Tadayoshi Sato <[email protected]>
AuthorDate: Tue Apr 12 16:13:48 2022 +0900

    fix(e2e): resolve Camel version from catalog for test local
---
 e2e/local/local_build_test.go           | 26 +++++++++++++++++++-------
 pkg/util/camel/camel_runtime_catalog.go |  5 +++++
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/e2e/local/local_build_test.go b/e2e/local/local_build_test.go
index 8388d83dc..ab3440b4b 100644
--- a/e2e/local/local_build_test.go
+++ b/e2e/local/local_build_test.go
@@ -33,11 +33,23 @@ import (
        . "github.com/apache/camel-k/e2e/support"
        testutil "github.com/apache/camel-k/e2e/support/util"
        "github.com/apache/camel-k/pkg/util"
+       "github.com/apache/camel-k/pkg/util/camel"
 )
 
 // Camel version used to validate the test results
-// TODO: read version for the Camel catalog
-var camelVersion = "3.14.1"
+var camelVersion = getCamelVersion()
+
+func getCamelVersion() string {
+       catalog, err := camel.DefaultCatalog()
+       if err != nil {
+               panic(err)
+       }
+       version := catalog.GetCamelVersion()
+       if version == "" {
+               panic("unable to resolve the Camel version from catalog")
+       }
+       return version
+}
 
 func TestLocalBuild(t *testing.T) {
        RegisterTestingT(t)
@@ -99,11 +111,6 @@ func TestLocalBuildWithTrait(t *testing.T) {
        Eventually(DockerImages, 
TestTimeoutMedium).Should(ContainSubstring(image))
 }
 
-func dependency(dir string, jar string, params ...interface{}) string {
-       params = append([]interface{}{dir}, params...)
-       return fmt.Sprintf("%s/dependencies/"+jar, params...)
-}
-
 func TestLocalBuildIntegrationDirectory(t *testing.T) {
        RegisterTestingT(t)
 
@@ -230,3 +237,8 @@ func TestLocalBuildModelineDependencies(t *testing.T) {
        Eventually(dependency(dir, "com.github.squakez.samplejp-v1.0.jar"), 
TestTimeoutMedium).Should(BeAnExistingFile())
        Eventually(dir+"/routes/dependency.groovy", 
TestTimeoutShort).Should(BeAnExistingFile())
 }
+
+func dependency(dir string, jar string, params ...interface{}) string {
+       params = append([]interface{}{dir}, params...)
+       return fmt.Sprintf("%s/dependencies/"+jar, params...)
+}
diff --git a/pkg/util/camel/camel_runtime_catalog.go 
b/pkg/util/camel/camel_runtime_catalog.go
index 787370a5f..511541911 100644
--- a/pkg/util/camel/camel_runtime_catalog.go
+++ b/pkg/util/camel/camel_runtime_catalog.go
@@ -129,6 +129,11 @@ func (c *RuntimeCatalog) GetJavaTypeDependency(camelType 
string) (string, bool)
        return javaType, ok
 }
 
+// GetCamelVersion returns the Camel version the runtime is based on.
+func (c *RuntimeCatalog) GetCamelVersion() string {
+       return c.Runtime.Metadata["camel.version"]
+}
+
 // VisitArtifacts --.
 func (c *RuntimeCatalog) VisitArtifacts(visitor func(string, v1.CamelArtifact) 
bool) {
        for id, artifact := range c.Artifacts {

Reply via email to