-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added acceptance test suite Signed-off-by: Andrew Meyer <ameyer@pivotal.io> Signed-off-by: Javier Romero <jromero@pivotal.io>
- Loading branch information
1 parent
f0fa0c3
commit e632d95
Showing
12 changed files
with
184 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
sudo: required | ||
services: | ||
- docker | ||
|
||
install: | ||
- set -e | ||
|
||
jobs: | ||
include: | ||
- stage: unit test | ||
language: go | ||
go: | ||
- 1.11.x | ||
- 1.12.x | ||
env: | ||
- GO111MODULE=on | ||
go_import_path: github.com/buildpack/lifecycle | ||
script: | | ||
make test | ||
branches: | ||
only: | ||
- master |
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,87 @@ | ||
// +build acceptance | ||
|
||
package acceptance | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/sclevine/spec" | ||
"github.com/sclevine/spec/report" | ||
|
||
h "github.com/buildpack/lifecycle/testhelpers" | ||
) | ||
|
||
func TestAcceptance(t *testing.T) { | ||
spec.Run(t, "acceptance", testAcceptance, spec.Sequential(), spec.Report(report.Terminal{})) | ||
} | ||
|
||
func testAcceptance(t *testing.T, when spec.G, it spec.S) { | ||
|
||
when("All", func() { | ||
when("version flag is set", func() { | ||
for _, data := range [][]string{ | ||
{"analyzer: only -version is present", "analyzer -version"}, | ||
{"analyzer: other params are set", "analyzer -daemon -version some/image"}, | ||
|
||
{"builder: only -version is present", "builder -version"}, | ||
{"builder: other params are set", "builder -app=/some/dir -version some/image"}, | ||
|
||
{"cacher: only -version is present", "cacher -version"}, | ||
{"cacher: other params are set", "cacher -path=/some/dir -version"}, | ||
|
||
{"detector: only -version is present", "detector -version"}, | ||
{"detector: other params are set", "detector -app=/some/dir -version"}, | ||
|
||
{"exporter: only -version is present", "exporter -version"}, | ||
{"exporter: other params are set", "exporter -analyzed=/some/file -version some/image"}, | ||
|
||
{"restorer: only -version is present", "restorer -version"}, | ||
{"restorer: other params are set", "restorer -path=/some/dir -version"}, | ||
} { | ||
desc := data[0] | ||
binary, args := parseCommand(data[1]) | ||
|
||
when(desc, func() { | ||
it("only prints the version", func() { | ||
output, err := lifecycleCmd(t, binary, args...).CombinedOutput() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
h.AssertStringContains(t, string(output), "some-version") | ||
}) | ||
}) | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
func lifecycleCmd(t *testing.T, name string, args ...string) *exec.Cmd { | ||
cmdArgs := append( | ||
[]string{ | ||
"run", | ||
"-ldflags", "-X github.com/buildpack/lifecycle/cmd.buildVersion=some-version", | ||
"./cmd/" + name + "/main.go", | ||
}, args..., | ||
) | ||
|
||
wd, err := os.Getwd() | ||
h.AssertNil(t, err) | ||
|
||
cmd := exec.Command( | ||
"go", | ||
cmdArgs..., | ||
) | ||
cmd.Dir = filepath.Dir(wd) | ||
|
||
return cmd | ||
} | ||
|
||
func parseCommand(command string) (binary string, args []string) { | ||
parts := strings.Split(command, " ") | ||
return parts[0], parts[1:] | ||
} |
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
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
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
Oops, something went wrong.