Skip to content

Commit

Permalink
fix(test): code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Mar 9, 2023
1 parent a2e4aaf commit e09e90b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
8 changes: 0 additions & 8 deletions e2e/namespace/install/cli/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ func TestKamelCLIDelete(t *testing.T) {
Eventually(IntegrationPod(ns, "yaml"), TestTimeoutMedium).Should(BeNil())
})

t.Run("delete integration from csv", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "github:apache/camel-k/e2e/namespace/install/cli/files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
Eventually(Integration(ns, "yaml")).Should(BeNil())
Eventually(IntegrationPod(ns, "yaml"), TestTimeoutMedium).Should(BeNil())
})

t.Run("delete several integrations", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed())
Expect(KamelRunWithID(operatorID, ns, "../files/Java.java").Execute()).To(Succeed())
Expand Down
20 changes: 11 additions & 9 deletions e2e/namespace/install/cli/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)

var sampleJar = "https://raw.githubusercontent.com/apache/camel-k/main/e2e/common/traits/files/jvm/sample-1.0.jar"

func TestKamelCLIRun(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
Expand All @@ -44,33 +46,33 @@ func TestKamelCLIRun(t *testing.T) {
t.Run("Examples from GitHub", func(t *testing.T) {
t.Run("Java", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns,
"github:apache/camel-k/e2e/namespace/install/files/Java.java").Execute()).To(Succeed())
"github:apache/camel-k-examples/generic-examples/languages/Sample.java", "--name", "java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
})

t.Run("Java (RAW)", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns,
"https://raw.githubusercontent.com/apache/camel-k/main/e2e/namespace/install/files/Java.java").Execute()).
"https://raw.githubusercontent.com/apache/camel-k-examples/main/generic-examples/languages/Sample.java", "--name", "java").Execute()).
To(Succeed())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
})

t.Run("Java (branch)", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns,
"github:apache/camel-k/e2e/namespace/install/files/Java.java?branch=main").Execute()).To(Succeed())
"github:apache/camel-k-examples/generic-examples/languages/Sample.java?branch=main", "--name", "java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Hello Camel K!"))
Eventually(DeleteIntegrations(ns), TestTimeoutLong).Should(Equal(0))
})

t.Run("Gist (ID)", func(t *testing.T) {
Expand Down

0 comments on commit e09e90b

Please sign in to comment.