MCPcopy
hub / github.com/cloudfoundry/cli / WithProcfileApp

Function WithProcfileApp

integration/helpers/app.go:139–186  ·  view source on GitHub ↗

WithProcfileApp creates an application to use with your CLI command that contains Procfile defining web and worker processes.

(f func(dir string))

Source from the content-addressed store, hash-verified

137// WithProcfileApp creates an application to use with your CLI command
138// that contains Procfile defining web and worker processes.
139func WithProcfileApp(f func(dir string)) {
140 dir := TempDirAbsolutePath("", "simple-ruby-app")
141 defer os.RemoveAll(dir)
142
143 err := os.WriteFile(filepath.Join(dir, "Procfile"), []byte(`---
144web: ruby -run -e httpd . -p $PORT
145console: bundle exec irb`,
146 ), 0666)
147 Expect(err).ToNot(HaveOccurred())
148
149 //TODO: Remove the ruby version once bundler issue(https://github.com/rubygems/rubygems/issues/6280)
150 // is solved
151 err = os.WriteFile(filepath.Join(dir, "Gemfile"), []byte(`source 'http://rubygems.org'
152ruby '~> 3.0'
153gem 'irb'
154gem 'webrick'`,
155 ), 0666)
156 Expect(err).ToNot(HaveOccurred())
157
158 err = os.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(`
159GEM
160 remote: http://rubygems.org/
161 specs:
162 io-console (0.6.0)
163 irb (1.6.4)
164 reline (>= 0.3.0)
165 reline (0.3.3)
166 io-console (~> 0.5)
167 webrick (1.8.1)
168
169PLATFORMS
170 ruby
171
172DEPENDENCIES
173 irb
174 webrick
175
176RUBY VERSION
177 ruby 3.3.1p55
178
179BUNDLED WITH
180 2.5.18
181`,
182 ), 0666)
183 Expect(err).ToNot(HaveOccurred())
184
185 f(dir)
186}
187
188// WithCrashingApp creates an application to use with your CLI command
189// that will not successfully start its `web` process

Calls 1

TempDirAbsolutePathFunction · 0.85

Tested by

no test coverage detected