Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions acceptance/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ fail: fail_detect_buildpack@some_version`
detectImage,
h.WithFlags("--user", userID,
"--env", "CNB_ORDER_PATH=/cnb/orders/middle_order.toml",
"--env", "CNB_SYSTEM_PATH=/cnb/system.toml",
"--env", "CNB_SYSTEM_PATH=/cnb/test-data/system.toml",
"--env", "CNB_PLATFORM_API="+platformAPI,
),
h.WithArgs("-log-level=debug"),
Expand All @@ -475,13 +475,16 @@ fail: fail_detect_buildpack@some_version`
h.AssertEq(t, group.Group[2].Version, "simple_buildpack_version")

// check output contains all buildpacks
h.AssertStringContains(t, output, "always_detect_buildpack always_detect_buildpack_version")
h.AssertStringContains(t, output, "buildpack_for_ext buildpack_for_ext_version")
h.AssertStringContains(t, output, "simple_buildpack simple_buildpack_version")
h.AssertStringContains(t, output, "always_detect_buildpack")
h.AssertStringContains(t, output, "always_detect_buildpack_version")
h.AssertStringContains(t, output, "buildpack_for_ext")
h.AssertStringContains(t, output, "buildpack_for_ext_version")
h.AssertStringContains(t, output, "simple_buildpack")
h.AssertStringContains(t, output, "simple_buildpack_version")

// check debug logs show system buildpack merging
h.AssertStringContains(t, output, "Prepending 1 system buildpack(s) to order")
h.AssertStringContains(t, output, "Appending 1 system buildpack(s) to order")
h.AssertStringContains(t, output, "Prepending 1 system buildpack(s) to group")
h.AssertStringContains(t, output, "Appending 1 system buildpack(s) to group")
})
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

## always detect

platform_path=$1
plan_path=$2

echo "ENV"
env

echo "platform_path: $platform_path"
echo "app_dir: $(pwd)"

cat >> "${plan_path}" <<EOL
[[provides]]
name = "some_requirement"
EOL
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
api = "0.10"

[buildpack]
id = "always_detect_buildpack"
version = "always_detect_buildpack_version"
name = "Always Detect Buildpack"
8 changes: 8 additions & 0 deletions phase/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {
configHandler,
dirStore,
)

// Mock ReadSystem for Platform API >= 0.15 (returns empty by default)
if api.Platform.Latest().AtLeast("0.15") {
configHandler.EXPECT().ReadSystem(gomock.Any(), gomock.Any()).Return(files.System{}, nil).AnyTimes()
}
})

it.After(func() {
Expand Down Expand Up @@ -99,6 +104,8 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {

when("Platform API >= 0.15", func() {
it("reads and merges system buildpacks", func() {
configHandler = testmock.NewMockConfigHandler(mockController)

detectorFactory015 := phase.NewHermeticFactory(
api.MustParse("0.15"),
apiVerifier,
Expand All @@ -121,6 +128,7 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {
},
},
}
configHandler.EXPECT().ReadAnalyzed("some-analyzed-path", gomock.Any()).Return(files.Analyzed{}, nil)
configHandler.EXPECT().ReadOrder("some-order-path").Return(order, nil, nil)
configHandler.EXPECT().ReadSystem("some-system-path", gomock.Any()).Return(system, nil)

Expand Down
2 changes: 1 addition & 1 deletion priv/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func DockerClient() (*client.Client, error) {
}
opts = append(opts, opt)
}
return client.NewClientWithOpts(opts...)
return client.New(opts...)
}

type unclosableConn struct {
Expand Down
2 changes: 1 addition & 1 deletion testhelpers/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
func DockerCli(t *testing.T) dockercli.APIClient {
dockerCliOnce.Do(func() {
var dockerCliErr error
dockerCliVal, dockerCliErr = dockercli.NewClientWithOpts(dockercli.FromEnv, dockercli.WithVersion("1.38"))
dockerCliVal, dockerCliErr = dockercli.New(dockercli.FromEnv)
AssertNil(t, dockerCliErr)
})
return dockerCliVal
Expand Down
2 changes: 1 addition & 1 deletion tools/image/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {

var img imgutil.Image
if useDaemon {
dockerClient, err := dockercli.NewClientWithOpts(dockercli.FromEnv, dockercli.WithVersion("1.38"))
dockerClient, err := dockercli.New(dockercli.FromEnv)
if err != nil {
log.Fatal("Failed to initialize docker client:", err)
}
Expand Down
Loading