From 47b2f3846568430f61394dc5abdfbf9ede5f3100 Mon Sep 17 00:00:00 2001
From: janisar007 <janisarakhtaransari007@gmail.com>
Date: Wed, 4 Dec 2024 17:52:46 +0530
Subject: [PATCH] Revert "remove go version check"

This reverts commit 27df7fbf1dd119f4514b105f6d862c8d5db0ee58.
---
 integration/build_flags_test.go     |  2 ++
 integration/default_test.go         | 26 +++++++++++++++++++-------
 integration/import_path_test.go     |  9 ++++++++-
 integration/keep_files_test.go      |  1 +
 integration/mod_test.go             |  4 ++--
 integration/targets_test.go         |  4 ++--
 integration/testdata/mod/main.go    |  4 ----
 integration/testdata/vendor/main.go |  4 ----
 integration/vendor_test.go          |  4 ++--
 9 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/integration/build_flags_test.go b/integration/build_flags_test.go
index 6ca3e33..f0750de 100644
--- a/integration/build_flags_test.go
+++ b/integration/build_flags_test.go
@@ -75,6 +75,7 @@ func testBuildFlags(t *testing.T, context spec.G, it spec.S) {
 			Eventually(container).Should(
 				Serve(
 					SatisfyAll(
+						ContainSubstring("go1.21"),
 						ContainSubstring(`variable value: "some-value"`),
 						ContainSubstring("/workspace contents: []"),
 					),
@@ -122,6 +123,7 @@ func testBuildFlags(t *testing.T, context spec.G, it spec.S) {
 			Eventually(container).Should(
 				Serve(
 					SatisfyAll(
+						ContainSubstring("go1.21"),
 						ContainSubstring(`variable value: "env-value"`),
 						ContainSubstring("/workspace contents: []"),
 					),
diff --git a/integration/default_test.go b/integration/default_test.go
index 38aea9e..11098b0 100644
--- a/integration/default_test.go
+++ b/integration/default_test.go
@@ -82,7 +82,14 @@ func testDefault(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
+			Eventually(container).Should(
+				Serve(
+					SatisfyAll(
+						ContainSubstring("go1.21"),
+						ContainSubstring("/workspace contents: []"),
+					),
+				).OnPort(8080),
+			)
 
 			Expect(logs).To(ContainLines(
 				MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)),
@@ -165,8 +172,7 @@ func testDefault(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
-
+			Eventually(container).Should(Serve(ContainSubstring("go1.21")).OnPort(8080))
 		})
 	})
 
@@ -214,7 +220,14 @@ func testDefault(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
+			Eventually(container).Should(
+				Serve(
+					SatisfyAll(
+						ContainSubstring("go1.21"),
+						ContainSubstring("/workspace contents: []"),
+					),
+				).OnPort(8080),
+			)
 		})
 	})
 
@@ -270,8 +283,7 @@ func testDefault(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
-
+			Eventually(container).Should(Serve(ContainSubstring("go1.21")).OnPort(8080))
 
 			Expect(logs).To(ContainLines(
 				"  Assigning launch processes:",
@@ -287,7 +299,7 @@ func testDefault(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(noReloadContainer).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
+			Eventually(noReloadContainer).Should(Serve(ContainSubstring("go1.21")).OnPort(8080))
 		})
 	})
 }
diff --git a/integration/import_path_test.go b/integration/import_path_test.go
index 6c91835..05a174b 100644
--- a/integration/import_path_test.go
+++ b/integration/import_path_test.go
@@ -72,7 +72,14 @@ func testImportPath(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
+			Eventually(container).Should(
+				Serve(
+					SatisfyAll(
+						ContainSubstring("go1.21"),
+						ContainSubstring("/workspace contents: []"),
+					),
+				).OnPort(8080),
+			)
 		})
 	})
 }
diff --git a/integration/keep_files_test.go b/integration/keep_files_test.go
index 74149fe..7e11133 100644
--- a/integration/keep_files_test.go
+++ b/integration/keep_files_test.go
@@ -75,6 +75,7 @@ func testKeepFiles(t *testing.T, context spec.G, it spec.S) {
 			Eventually(container).Should(
 				Serve(
 					SatisfyAll(
+						ContainSubstring("go1.21"),
 						ContainSubstring("/workspace contents: [/workspace/assets /workspace/static-file]"),
 						ContainSubstring("file contents: Hello world!"),
 					),
diff --git a/integration/mod_test.go b/integration/mod_test.go
index eaf4baa..73a32d8 100644
--- a/integration/mod_test.go
+++ b/integration/mod_test.go
@@ -82,7 +82,7 @@ func testMod(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
+			Eventually(container).Should(Serve(ContainSubstring("go1.21")).OnPort(8080))
 
 			// check that all required SBOM files are present
 			Expect(filepath.Join(sbomDir, "sbom", "launch", strings.ReplaceAll(settings.Buildpack.ID, "/", "_"), "targets", "sbom.cdx.json")).To(BeARegularFile())
@@ -119,7 +119,7 @@ func testMod(t *testing.T, context spec.G, it spec.S) {
 					Execute(image.ID)
 				Expect(err).NotTo(HaveOccurred())
 
-				Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
+				Eventually(container).Should(Serve(ContainSubstring("go1.21")).OnPort(8080))
 
 				// check that all required SBOM files are present
 				Expect(filepath.Join(sbomDir, "sbom", "launch", strings.ReplaceAll(settings.Buildpack.ID, "/", "_"), "targets", "sbom.cdx.json")).To(BeARegularFile())
diff --git a/integration/targets_test.go b/integration/targets_test.go
index 17720e0..02eaef6 100644
--- a/integration/targets_test.go
+++ b/integration/targets_test.go
@@ -86,7 +86,7 @@ func testTargets(t *testing.T, context spec.G, it spec.S) {
 			Expect(err).NotTo(HaveOccurred())
 			containerIDs[container.ID] = struct{}{}
 
-			Eventually(container).Should(Serve(ContainSubstring("first: go")).OnPort(8080))
+			Eventually(container).Should(Serve(ContainSubstring("first: go1.21")).OnPort(8080))
 
 			Expect(logs).To(ContainLines(
 				"  Assigning launch processes:",
@@ -104,7 +104,7 @@ func testTargets(t *testing.T, context spec.G, it spec.S) {
 			Expect(err).NotTo(HaveOccurred())
 			containerIDs[container.ID] = struct{}{}
 
-			Eventually(container).Should(Serve(ContainSubstring("second: go")).OnPort(8080))
+			Eventually(container).Should(Serve(ContainSubstring("second: go1.21")).OnPort(8080))
 
 			// check that all required SBOM files are present
 			Expect(filepath.Join(sbomDir, "sbom", "launch", strings.ReplaceAll(settings.Buildpack.ID, "/", "_"), "targets", "sbom.cdx.json")).To(BeARegularFile())
diff --git a/integration/testdata/mod/main.go b/integration/testdata/mod/main.go
index 23d6c21..762d3cd 100644
--- a/integration/testdata/mod/main.go
+++ b/integration/testdata/mod/main.go
@@ -5,7 +5,6 @@ import (
 	"log"
 	"net/http"
 	"os"
-	"path/filepath"
 	"runtime"
 
 	"github.com/gorilla/mux"
@@ -15,9 +14,6 @@ func main() {
 	router := mux.NewRouter()
 	router.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
 		fmt.Fprintln(w, runtime.Version())
-
-		paths, _ := filepath.Glob("/workspace/*")
-		fmt.Fprintf(w, "/workspace contents: %v\n", paths)
 	})
 
 	log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), router))
diff --git a/integration/testdata/vendor/main.go b/integration/testdata/vendor/main.go
index 685c7ff..05e564e 100644
--- a/integration/testdata/vendor/main.go
+++ b/integration/testdata/vendor/main.go
@@ -6,7 +6,6 @@ import (
 	"log"
 	"net/http"
 	"os"
-	"path/filepath"
 	"runtime"
 
 	"github.com/gorilla/mux"
@@ -19,9 +18,6 @@ func main() {
 	router := mux.NewRouter()
 	router.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
 		fmt.Fprintln(w, runtime.Version())
-
-		paths, _ := filepath.Glob("/workspace/*")
-		fmt.Fprintf(w, "/workspace contents: %v\n", paths)
 	})
 
 	log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), router))
diff --git a/integration/vendor_test.go b/integration/vendor_test.go
index b536eb7..b2bfe2f 100644
--- a/integration/vendor_test.go
+++ b/integration/vendor_test.go
@@ -71,7 +71,7 @@ func testVendor(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
+			Eventually(container).Should(Serve(ContainSubstring("go1.21")).OnPort(8080))
 		})
 	})
 
@@ -120,7 +120,7 @@ func testVendor(t *testing.T, context spec.G, it spec.S) {
 				Execute(image.ID)
 			Expect(err).NotTo(HaveOccurred())
 
-			Eventually(container).Should(Serve(ContainSubstring("/workspace contents: []")).OnPort(8080))
+			Eventually(container).Should(Serve(ContainSubstring("go1.21")).OnPort(8080))
 		})
 	})
 }