-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add test to ensure toggle layer not added when using Native Image
- Loading branch information
1 parent
e0da05f
commit 82d63a9
Showing
1 changed file
with
31 additions
and
2 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 |
---|---|---|
|
@@ -24,7 +24,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { | |
ctx libcnb.BuildContext | ||
) | ||
|
||
it("contributes Java agent API <= 0.6", func() { | ||
it("contributes Java agent API <= 0.6 and toggle", func() { | ||
ctx.Plan.Entries = append(ctx.Plan.Entries, libcnb.BuildpackPlanEntry{Name: "datadog-java"}) | ||
ctx.Buildpack.Metadata = map[string]interface{}{ | ||
"dependencies": []map[string]interface{}{ | ||
|
@@ -46,7 +46,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { | |
Expect(result.Layers[1].Name()).To(Equal("helper")) | ||
}) | ||
|
||
it("contributes Java agent API >= 0.7", func() { | ||
it("contributes Java agent API >= 0.7 and toggle", func() { | ||
ctx.Plan.Entries = append(ctx.Plan.Entries, libcnb.BuildpackPlanEntry{Name: "datadog-java"}) | ||
ctx.Buildpack.Metadata = map[string]interface{}{ | ||
"dependencies": []map[string]interface{}{ | ||
|
@@ -70,6 +70,35 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { | |
Expect(result.Layers[1].Name()).To(Equal("helper")) | ||
}) | ||
|
||
context("using Native Image", func() { | ||
it.Before(func() { | ||
t.Setenv("BP_NATIVE_IMAGE", "true") | ||
}) | ||
|
||
it("contributes Java agent API >= 0.7 only", func() { | ||
ctx.Plan.Entries = append(ctx.Plan.Entries, libcnb.BuildpackPlanEntry{Name: "datadog-java"}) | ||
ctx.Buildpack.Metadata = map[string]interface{}{ | ||
"dependencies": []map[string]interface{}{ | ||
{ | ||
"id": "datadog-agent-java", | ||
"version": "1.1.1", | ||
"stacks": []interface{}{"test-stack-id"}, | ||
"cpes": []interface{}{"cpe:2.3:a:datadog-agent:java-agent:1.1.1:*:*:*:*:*:*:*"}, | ||
"purl": "pkg:generic/[email protected]?arch=amd64", | ||
}, | ||
}, | ||
} | ||
ctx.Buildpack.API = "0.7" | ||
ctx.StackID = "test-stack-id" | ||
|
||
result, err := datadog.Build{}.Build(ctx) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
Expect(result.Layers).To(HaveLen(1)) | ||
Expect(result.Layers[0].Name()).To(Equal("datadog-agent-java")) | ||
}) | ||
}) | ||
|
||
it("contributes NodeJS agent API <= 0.6", func() { | ||
ctx.Plan.Entries = append(ctx.Plan.Entries, libcnb.BuildpackPlanEntry{Name: "datadog-nodejs"}) | ||
ctx.Buildpack.Metadata = map[string]interface{}{ | ||
|