From 2ae190c0d4eb9c9d25f39a12ba120a3e3ab5e03d Mon Sep 17 00:00:00 2001 From: Johannes Dillmann Date: Thu, 19 Sep 2024 15:09:10 +0200 Subject: [PATCH] use new JS hello world app for cnb integration Co-authored-by: Pavel Busko --- integration/assets/js-hello/index.js | 12 ++++++++++++ integration/assets/js-hello/package.json | 8 ++++++++ integration/helpers/app.go | 5 +++++ integration/v7/isolated/app_command_test.go | 6 +++--- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 integration/assets/js-hello/index.js create mode 100644 integration/assets/js-hello/package.json diff --git a/integration/assets/js-hello/index.js b/integration/assets/js-hello/index.js new file mode 100644 index 00000000000..ed10e718435 --- /dev/null +++ b/integration/assets/js-hello/index.js @@ -0,0 +1,12 @@ +const http = require('http'); + +const server = http.createServer((_req, res) => { + res.statusCode = 200; + res.setHeader('Content-Type', 'text/plain'); + res.end('Hello World\n'); +}); + +const port = process.env.PORT; +server.listen(port, "0.0.0.0", () => { + console.log(`Server running at http://0.0.0.0:${port}/`); +}); diff --git a/integration/assets/js-hello/package.json b/integration/assets/js-hello/package.json new file mode 100644 index 00000000000..5d4ef7f9cff --- /dev/null +++ b/integration/assets/js-hello/package.json @@ -0,0 +1,8 @@ +{ + "name": "js-hello", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "start": "node ./index.js" + } +} diff --git a/integration/helpers/app.go b/integration/helpers/app.go index 1943ddbacc8..f2cd7458ead 100644 --- a/integration/helpers/app.go +++ b/integration/helpers/app.go @@ -129,6 +129,11 @@ func WithMultiBuildpackApp(f func(dir string)) { f("../../assets/go_calls_ruby") } +// WithJSHelloWorld creates a simple JS Hello World HTTP application to use with the CF push command. +func WithJSHelloWorld(f func(dir string)) { + f("../../assets/js-hello") +} + // WithProcfileApp creates an application to use with your CLI command // that contains Procfile defining web and worker processes. func WithProcfileApp(f func(dir string)) { diff --git a/integration/v7/isolated/app_command_test.go b/integration/v7/isolated/app_command_test.go index db9375d0c6d..9b812b40bc3 100644 --- a/integration/v7/isolated/app_command_test.go +++ b/integration/v7/isolated/app_command_test.go @@ -409,14 +409,14 @@ applications: When("the app is a CNB app", func() { BeforeEach(func() { - helpers.WithProcfileApp(func(appDir string) { - Eventually(helpers.CF("push", appName, "-p", appDir, "--lifecycle", "cnb", "-b", "docker://gcr.io/paketo-buildpacks/ruby:latest")).Should(Exit()) + helpers.WithJSHelloWorld(func(appDir string) { + Eventually(helpers.CF("push", appName, "-p", appDir, "--lifecycle", "cnb", "-b", "docker://gcr.io/paketo-buildpacks/nodejs:latest")).Should(Exit()) }) }) It("displays the app buildpacks", func() { session := helpers.CF("app", appName) - Eventually(session).Should(Say(`paketo-buildpacks\/ruby`)) + Eventually(session).Should(Say(`paketo-buildpacks\/nodejs`)) Eventually(session).Should(Exit(0)) }) })