-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2123 from buildpacks/fix/bp-new
Fix pack buildpack new --targets
- Loading branch information
Showing
14 changed files
with
269 additions
and
247 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 |
---|---|---|
|
@@ -97,14 +97,14 @@ func testBuildpackNewCommand(t *testing.T, when spec.G, it spec.S) { | |
Arch: "arm", | ||
ArchVariant: "v6", | ||
Distributions: []dist.Distribution{{ | ||
Name: "ubuntu", | ||
Versions: []string{"14.04", "16.04"}, | ||
Name: "ubuntu", | ||
Version: "14.04", | ||
}}, | ||
}}, | ||
}).Return(nil).MaxTimes(1) | ||
|
||
path := filepath.Join(tmpDir, "targets") | ||
command.SetArgs([]string{"--path", path, "example/targets", "--targets", "linux/arm/v6:[email protected]@16.04"}) | ||
command.SetArgs([]string{"--path", path, "example/targets", "--targets", "linux/arm/v6:[email protected]"}) | ||
|
||
err := command.Execute() | ||
h.AssertNil(t, err) | ||
|
@@ -120,8 +120,11 @@ func testBuildpackNewCommand(t *testing.T, when spec.G, it spec.S) { | |
Arch: "arm", | ||
ArchVariant: "v6", | ||
Distributions: []dist.Distribution{{ | ||
Name: "ubuntu", | ||
Versions: []string{"14.04", "16.04"}, | ||
Name: "ubuntu", | ||
Version: "14.04", | ||
}, { | ||
Name: "ubuntu", | ||
Version: "16.04", | ||
}}, | ||
}}, | ||
}).Return(nil).MaxTimes(1) | ||
|
@@ -133,7 +136,7 @@ func testBuildpackNewCommand(t *testing.T, when spec.G, it spec.S) { | |
h.AssertNotNil(t, err) | ||
}) | ||
when("it should", func() { | ||
it("support format [os][/arch][/variant]:[name@version@version2];[some-name@version@version2]", func() { | ||
it("support format [os][/arch][/variant]:[name@version];[some-name@version]", func() { | ||
mockClient.EXPECT().NewBuildpack(gomock.Any(), client.NewBuildpackOptions{ | ||
API: "0.8", | ||
ID: "example/targets", | ||
|
@@ -146,12 +149,12 @@ func testBuildpackNewCommand(t *testing.T, when spec.G, it spec.S) { | |
ArchVariant: "v6", | ||
Distributions: []dist.Distribution{ | ||
{ | ||
Name: "ubuntu", | ||
Versions: []string{"14.04", "16.04"}, | ||
Name: "ubuntu", | ||
Version: "14.04", | ||
}, | ||
{ | ||
Name: "debian", | ||
Versions: []string{"8.10", "10.9"}, | ||
Name: "debian", | ||
Version: "8.10", | ||
}, | ||
}, | ||
}, | ||
|
@@ -160,16 +163,16 @@ func testBuildpackNewCommand(t *testing.T, when spec.G, it spec.S) { | |
Arch: "amd64", | ||
Distributions: []dist.Distribution{ | ||
{ | ||
Name: "windows-nano", | ||
Versions: []string{"10.0.19041.1415"}, | ||
Name: "windows-nano", | ||
Version: "10.0.19041.1415", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}).Return(nil).MaxTimes(1) | ||
|
||
path := filepath.Join(tmpDir, "targets") | ||
command.SetArgs([]string{"--path", path, "example/targets", "--targets", "linux/arm/v6:[email protected]@16.04;[email protected]@10.9", "-t", "windows/amd64:[email protected]"}) | ||
command.SetArgs([]string{"--path", path, "example/targets", "--targets", "linux/arm/v6:[email protected];[email protected]", "-t", "windows/amd64:[email protected]"}) | ||
|
||
err := command.Execute() | ||
h.AssertNil(t, err) | ||
|
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 |
---|---|---|
|
@@ -61,13 +61,14 @@ func testParseTargets(t *testing.T, when spec.G, it spec.S) { | |
h.AssertNotEq(t, outBuf.String(), "") | ||
}) | ||
}) | ||
|
||
when("target#ParseTargets", func() { | ||
it("should throw an error when atleast one target throws error", func() { | ||
_, err := target.ParseTargets([]string{"linux/arm/v6", ":distro@version"}, logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
h.AssertNotNil(t, err) | ||
}) | ||
it("should parse targets as expected", func() { | ||
output, err := target.ParseTargets([]string{"linux/arm/v6", "linux/amd64:[email protected];[email protected]@10.06"}, logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
output, err := target.ParseTargets([]string{"linux/arm/v6", "linux/amd64:[email protected];[email protected];debian@10.06"}, logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
h.AssertNil(t, err) | ||
h.AssertEq(t, output, []dist.Target{ | ||
{ | ||
|
@@ -80,47 +81,66 @@ func testParseTargets(t *testing.T, when spec.G, it spec.S) { | |
Arch: "amd64", | ||
Distributions: []dist.Distribution{ | ||
{ | ||
Name: "ubuntu", | ||
Versions: []string{"22.04"}, | ||
Name: "ubuntu", | ||
Version: "22.04", | ||
}, | ||
{ | ||
Name: "debian", | ||
Version: "8.10", | ||
}, | ||
{ | ||
Name: "debian", | ||
Versions: []string{"8.10", "10.06"}, | ||
Name: "debian", | ||
Version: "10.06", | ||
}, | ||
}, | ||
}, | ||
}) | ||
}) | ||
}) | ||
|
||
when("target#ParseDistro", func() { | ||
it("should parse distro as expected", func() { | ||
output, err := target.ParseDistro("[email protected]@20.08", logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
output, err := target.ParseDistro("[email protected]", logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
h.AssertEq(t, output, dist.Distribution{ | ||
Name: "ubuntu", | ||
Versions: []string{"22.04", "20.08"}, | ||
Name: "ubuntu", | ||
Version: "22.04", | ||
}) | ||
h.AssertNil(t, err) | ||
}) | ||
it("should return an error", func() { | ||
it("should return an error when name is missing", func() { | ||
_, err := target.ParseDistro("@[email protected]", logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
h.AssertNotNil(t, err) | ||
}) | ||
it("should return an error when there are two versions", func() { | ||
_, err := target.ParseDistro("[email protected]@20.08", logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
h.AssertNotNil(t, err) | ||
h.AssertError(t, err, "invalid distro") | ||
}) | ||
it("should warn when distro version is not specified", func() { | ||
target.ParseDistro("ubuntu", logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
h.AssertNotEq(t, outBuf.String(), "") | ||
}) | ||
}) | ||
|
||
when("target#ParseDistros", func() { | ||
it("should parse distros as expected", func() { | ||
output, err := target.ParseDistros("[email protected]@20.08;[email protected]@10.06", logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
output, err := target.ParseDistros("[email protected];ubuntu@20.08;[email protected];debian@10.06", logging.NewLogWithWriters(&outBuf, &outBuf)) | ||
h.AssertEq(t, output, []dist.Distribution{ | ||
{ | ||
Name: "ubuntu", | ||
Versions: []string{"22.04", "20.08"}, | ||
Name: "ubuntu", | ||
Version: "22.04", | ||
}, | ||
{ | ||
Name: "ubuntu", | ||
Version: "20.08", | ||
}, | ||
{ | ||
Name: "debian", | ||
Version: "8.10", | ||
}, | ||
{ | ||
Name: "debian", | ||
Versions: []string{"8.10", "10.06"}, | ||
Name: "debian", | ||
Version: "10.06", | ||
}, | ||
}) | ||
h.AssertNil(t, err) | ||
|
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.