Skip to content

Commit

Permalink
Merge branch 'release/0.11.0' into verbose-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jromero committed May 22, 2020
2 parents 9654c17 + d454c8e commit c5b9605
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
13 changes: 13 additions & 0 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,19 @@ func testWithoutSpecificBuilderRequirement(
})
})

when("trust-builder", func() {
it("sets the builder as trusted in ~/.pack/config.toml", func() {
h.SkipIf(t, !packSupports(packPath, "trust-builder"), "pack does not support 'trust-builder'")
builderName := "some-builder" + h.RandString(10)

h.Run(t, subjectPack("trust-builder", builderName))

packConfigFileContents, err := ioutil.ReadFile(filepath.Join(packHome, "config.toml"))
h.AssertNil(t, err)
h.AssertContains(t, string(packConfigFileContents), builderName)
})
})

when("package-buildpack", func() {
var tmpDir string

Expand Down
40 changes: 26 additions & 14 deletions package_buildpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/buildpacks/imgutil"
"github.com/buildpacks/imgutil/fakes"
"github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
"github.com/heroku/color"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
Expand Down Expand Up @@ -350,16 +351,6 @@ func testPackageBuildpack(t *testing.T, when spec.G, it spec.S) {
h.AssertNil(t, os.RemoveAll(tmpDir))
})

assertPackageBPFileHasBuildpacks := func(path string, parentBP dist.BuildpackDescriptor, otherBPs []dist.BuildpackDescriptor) {
packageBlob := blob.NewBlob(path)
mainBP, deps, err := buildpackage.BuildpacksFromOCILayoutBlob(packageBlob)
h.AssertNil(t, err)
h.AssertEq(t, mainBP.Descriptor(), parentBP)
for i, bp := range otherBPs {
h.AssertEq(t, deps[i].Descriptor(), bp)
}
}

when("dependencies are packaged buildpack image", func() {
it.Before(func() {
nestedPackage = fakes.NewImage("nested/package-"+h.RandString(12), "", nil)
Expand Down Expand Up @@ -390,7 +381,7 @@ func testPackageBuildpack(t *testing.T, when spec.G, it spec.S) {
Format: pack.FormatFile,
}))

assertPackageBPFileHasBuildpacks(packagePath, packageDescriptor, []dist.BuildpackDescriptor{childDescriptor})
assertPackageBPFileHasBuildpacks(t, packagePath, []dist.BuildpackDescriptor{packageDescriptor, childDescriptor})
})
})

Expand All @@ -409,7 +400,7 @@ func testPackageBuildpack(t *testing.T, when spec.G, it spec.S) {
Format: pack.FormatFile,
}))

assertPackageBPFileHasBuildpacks(packagePath, packageDescriptor, []dist.BuildpackDescriptor{childDescriptor})
assertPackageBPFileHasBuildpacks(t, packagePath, []dist.BuildpackDescriptor{packageDescriptor, childDescriptor})
})

when("dependency download fails", func() {
Expand Down Expand Up @@ -500,7 +491,7 @@ func testPackageBuildpack(t *testing.T, when spec.G, it spec.S) {
Format: pack.FormatFile,
}))

assertPackageBPFileHasBuildpacks(packagePath, packageDescriptor, []dist.BuildpackDescriptor{childDescriptor, secondChildDescriptor})
assertPackageBPFileHasBuildpacks(t, packagePath, []dist.BuildpackDescriptor{packageDescriptor, childDescriptor, secondChildDescriptor})
})
})

Expand Down Expand Up @@ -536,7 +527,7 @@ func testPackageBuildpack(t *testing.T, when spec.G, it spec.S) {
Format: pack.FormatFile,
}))

assertPackageBPFileHasBuildpacks(packagePath, packageDescriptor, []dist.BuildpackDescriptor{childDescriptor})
assertPackageBPFileHasBuildpacks(t, packagePath, []dist.BuildpackDescriptor{packageDescriptor, childDescriptor})
})
})
})
Expand All @@ -560,3 +551,24 @@ func testPackageBuildpack(t *testing.T, when spec.G, it spec.S) {
})
})
}

func assertPackageBPFileHasBuildpacks(t *testing.T, path string, descriptors []dist.BuildpackDescriptor) {
packageBlob := blob.NewBlob(path)
mainBP, depBPs, err := buildpackage.BuildpacksFromOCILayoutBlob(packageBlob)
h.AssertNil(t, err)
assertBuildpacksHaveDescriptors(t, append([]dist.Buildpack{mainBP}, depBPs...), descriptors)
}

func assertBuildpacksHaveDescriptors(t *testing.T, bps []dist.Buildpack, descriptors []dist.BuildpackDescriptor) {
h.AssertEq(t, len(bps), len(descriptors))
for _, bp := range bps {
found := false
for _, descriptor := range descriptors {
if diff := cmp.Diff(bp.Descriptor(), descriptor); diff == "" {
found = true
break
}
}
h.AssertTrue(t, found)
}
}

0 comments on commit c5b9605

Please sign in to comment.