-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds Rake to order grouping Co-authored-by: Frankie Gallina-Jones <frankieg@vmware.com>
- Loading branch information
1 parent
88ecabe
commit 4fa0bda
Showing
6 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package integration_test | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/paketo-buildpacks/occam" | ||
"github.com/sclevine/spec" | ||
|
||
. "github.com/onsi/gomega" | ||
. "github.com/paketo-buildpacks/occam/matchers" | ||
) | ||
|
||
func testRake(t *testing.T, context spec.G, it spec.S) { | ||
var ( | ||
Expect = NewWithT(t).Expect | ||
Eventually = NewWithT(t).Eventually | ||
|
||
pack occam.Pack | ||
docker occam.Docker | ||
) | ||
|
||
it.Before(func() { | ||
pack = occam.NewPack() | ||
docker = occam.NewDocker() | ||
}) | ||
|
||
context("when building a rake container", func() { | ||
var ( | ||
image occam.Image | ||
container occam.Container | ||
|
||
name string | ||
source string | ||
) | ||
|
||
it.Before(func() { | ||
var err error | ||
name, err = occam.RandomName() | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
it.After(func() { | ||
Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed()) | ||
Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed()) | ||
Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) | ||
Expect(os.RemoveAll(source)).To(Succeed()) | ||
}) | ||
|
||
context("uses the rake gem", func() { | ||
it("creates a working OCI image", func() { | ||
var err error | ||
source, err = occam.Source(filepath.Join("testdata", "rake")) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
var logs fmt.Stringer | ||
image, logs, err = pack.WithNoColor().Build. | ||
WithBuildpacks(rubyBuildpack). | ||
WithNoPull(). | ||
Execute(name, source) | ||
Expect(err).NotTo(HaveOccurred(), logs.String()) | ||
|
||
container, err = docker.Container.Run.Execute(image.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
rLogs := func() fmt.Stringer { | ||
rakeLogs, err := docker.Container.Logs.Execute(container.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
return rakeLogs | ||
} | ||
|
||
Eventually(rLogs).Should(ContainSubstring("I am a rake task")) | ||
|
||
Expect(logs).To(ContainLines(ContainSubstring("MRI Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Bundler Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Bundle Install Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Rake Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("bundle exec rake"))) | ||
}) | ||
}) | ||
|
||
context("does not use rake gem", func() { | ||
it("creates a working OCI image", func() { | ||
var err error | ||
source, err = occam.Source(filepath.Join("testdata", "rake_no_gem")) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
var logs fmt.Stringer | ||
image, logs, err = pack.WithNoColor().Build. | ||
WithBuildpacks(rubyBuildpack). | ||
WithNoPull(). | ||
Execute(name, source) | ||
Expect(err).NotTo(HaveOccurred(), logs.String()) | ||
|
||
container, err = docker.Container.Run.Execute(image.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
rLogs := func() fmt.Stringer { | ||
rakeLogs, err := docker.Container.Logs.Execute(container.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
return rakeLogs | ||
} | ||
|
||
Eventually(rLogs).Should(ContainSubstring("I am a rake task")) | ||
|
||
Expect(logs).To(ContainLines(ContainSubstring("MRI Buildpack"))) | ||
Expect(logs).NotTo(ContainLines(ContainSubstring("Bundler Buildpack"))) | ||
Expect(logs).NotTo(ContainLines(ContainSubstring("Bundle Install Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Rake Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("rake"))) | ||
}) | ||
}) | ||
|
||
context("when there is a Procfile", func() { | ||
it("creates a working OCI image that uses the start command from", func() { | ||
var err error | ||
source, err = occam.Source(filepath.Join("testdata", "rake")) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(ioutil.WriteFile(filepath.Join(source, "Procfile"), []byte("web: bundle exec rake proc"), 0644)).To(Succeed()) | ||
|
||
var logs fmt.Stringer | ||
image, logs, err = pack.WithNoColor().Build. | ||
WithBuildpacks(rubyBuildpack). | ||
WithNoPull(). | ||
Execute(name, source) | ||
Expect(err).NotTo(HaveOccurred(), logs.String()) | ||
|
||
container, err = docker.Container.Run.Execute(image.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
rLogs := func() fmt.Stringer { | ||
rakeLogs, err := docker.Container.Logs.Execute(container.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
return rakeLogs | ||
} | ||
|
||
Eventually(rLogs).Should(ContainSubstring("I am the proc rake task")) | ||
|
||
Expect(logs).To(ContainLines(ContainSubstring("MRI Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Bundler Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Bundle Install Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Rake Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Procfile Buildpack"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("bundle exec rake proc"))) | ||
}) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
ruby '~> 2.0' | ||
|
||
gem 'rake' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
task :simple do | ||
puts "I am a rake task" | ||
end | ||
|
||
task :default => [:simple] | ||
|
||
task :proc do | ||
puts "I am the proc rake task" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
task :simple do | ||
puts "I am a rake task" | ||
end | ||
|
||
task :default => [:simple] |