(platform switchblade.Platform, fixtures string)
| 12 | ) |
| 13 | |
| 14 | func testSpringBoot(platform switchblade.Platform, fixtures string) func(*testing.T, spec.G, spec.S) { |
| 15 | return func(t *testing.T, context spec.G, it spec.S) { |
| 16 | var ( |
| 17 | Expect = NewWithT(t).Expect |
| 18 | Eventually = NewWithT(t).Eventually |
| 19 | name string |
| 20 | ) |
| 21 | |
| 22 | it.Before(func() { |
| 23 | var err error |
| 24 | name, err = switchblade.RandomName() |
| 25 | Expect(err).NotTo(HaveOccurred()) |
| 26 | }) |
| 27 | |
| 28 | it.After(func() { |
| 29 | if t.Failed() && name != "" { |
| 30 | t.Logf("❌ FAILED TEST - App/Container: %s", name) |
| 31 | t.Logf(" Platform: %s", settings.Platform) |
| 32 | } |
| 33 | if name != "" && (!settings.KeepFailedContainers || !t.Failed()) { |
| 34 | Expect(platform.Delete.Execute(name)).To(Succeed()) |
| 35 | } |
| 36 | }) |
| 37 | |
| 38 | context("with a Spring Boot application", func() { |
| 39 | it("successfully deploys and runs", func() { |
| 40 | deployment, logs, err := platform.Deploy. |
| 41 | WithEnv(map[string]string{ |
| 42 | "BP_JAVA_VERSION": "11", |
| 43 | }). |
| 44 | Execute(name, filepath.Join(fixtures, "containers", "spring_boot_staged")) |
| 45 | Expect(err).NotTo(HaveOccurred(), logs.String) |
| 46 | |
| 47 | Expect(logs.String()).To(ContainSubstring("Java Buildpack")) |
| 48 | Eventually(deployment).Should(matchers.Serve(Not(BeEmpty()))) |
| 49 | }) |
| 50 | }) |
| 51 | |
| 52 | context("with embedded Tomcat", func() { |
| 53 | it("starts successfully", func() { |
| 54 | deployment, logs, err := platform.Deploy. |
| 55 | WithEnv(map[string]string{ |
| 56 | "BP_JAVA_VERSION": "11", |
| 57 | }). |
| 58 | Execute(name, filepath.Join(fixtures, "containers", "spring_boot_staged")) |
| 59 | Expect(err).NotTo(HaveOccurred(), logs.String) |
| 60 | |
| 61 | Expect(logs.String()).To(Or( |
| 62 | ContainSubstring("Tomcat"), |
| 63 | ContainSubstring("JRE"), |
| 64 | )) |
| 65 | Eventually(deployment).Should(matchers.Serve(Not(BeEmpty()))) |
| 66 | }) |
| 67 | }) |
| 68 | |
| 69 | context("with Java CFEnv", func() { |
| 70 | it("includes java-cfenv when Spring Boot is detected", func() { |
| 71 | deployment, logs, err := platform.Deploy. |
no test coverage detected