Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve command names, help output, and package layout #334

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
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
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,18 @@ Usage: kiln [options] <command> [<args>]
--version, -v bool prints the kiln release version (default: false)

Commands:
bake bakes a tile
cache-compiled-releases Cache compiled releases
fetch fetches releases
find-release-version prints a json string of a remote release satisfying the Kilnfile version and stemcell constraints
find-stemcell-version prints the latest stemcell version from Pivnet using the stemcell type listed in the Kilnfile
help prints this usage information
pre-process preprocess yaml files
publish publish tile on Pivnet
release-notes generates release notes from bosh-release release notes
sync-with-local update the Kilnfile.lock based on local releases
update-release bumps a release to a new version
update-stemcell updates stemcell and release information in Kilnfile.lock
upload-release uploads a BOSH release to an s3 release_source
validate validate Kilnfile and Kilnfile.lock
version prints the kiln release version
bake bakes a tile
cache-releases Cache compiled releases
create-release-notes generates release notes from bosh-release release notes
fetch-releases fetches releases
find-release-version prints a json string of a remote release satisfying the Kilnfile version and stemcell constraints
find-stemcell-version prints the latest stemcell version from Pivnet using the stemcell type listed in the Kilnfile
help prints this usage information
publish-release uploads a BOSH release to an s3 release_source
update-release bumps a release to a new version
update-stemcell updates stemcell and release information in Kilnfile.lock
validate validate Kilnfile and Kilnfile.lock
version prints the kiln release version
```

### `fetch`
Expand Down
6 changes: 0 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.18.1
github.com/pivotal-cf-experimental/gomegamatchers v0.0.0-20180326192815-e36bfcc98c3a
github.com/pivotal-cf/go-pivnet/v2 v2.0.11
github.com/pivotal-cf/jhanda v0.0.0-20200619200912-8de8eb943a43
github.com/pivotal-cf/om v0.0.0-20211027143906-30b10602e528
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
Expand All @@ -32,7 +31,6 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210707164159-52430bf6b52c // indirect
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/VividCortex/ewma v1.1.1 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/bmatcuk/doublestar v1.3.4 // indirect
Expand All @@ -47,7 +45,6 @@ require (
github.com/fatih/color v1.10.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
Expand All @@ -74,18 +71,15 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shirou/gopsutil v3.21.1+incompatible // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xanzy/ssh-agent v0.3.1 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20221006211917-84dc82d7e875 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/
github.com/ProtonMail/go-crypto v0.0.0-20210707164159-52430bf6b52c h1:FP7mMdsXy0ybzar1sJeIcZtaJka0U/ZmLTW4wRpolYk=
github.com/ProtonMail/go-crypto v0.0.0-20210707164159-52430bf6b52c/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
Expand Down Expand Up @@ -206,8 +205,6 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-ole/go-ole v0.0.0-20180625085808-7a0fa49edf48/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand Down Expand Up @@ -456,8 +453,6 @@ github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi
github.com/pivotal-cf-experimental/gomegamatchers v0.0.0-20180326192815-e36bfcc98c3a h1:K20a2viyp6kZgY41ESLne0eOXyY9DarmwA4q6zQ686w=
github.com/pivotal-cf-experimental/gomegamatchers v0.0.0-20180326192815-e36bfcc98c3a/go.mod h1:HdFegZwXOoRNyrqaOX6FC1zMkbA2k1/ktb2anj1E0K8=
github.com/pivotal-cf/go-pivnet v1.0.3/go.mod h1:rvEzWli4NJQhX7Z3z0DiEQXsPwC+uE//eIKcpl7S1as=
github.com/pivotal-cf/go-pivnet/v2 v2.0.11 h1:6tzC4zOr7acFPevfP32+8rEU567JlDobqiIejFf8aOc=
github.com/pivotal-cf/go-pivnet/v2 v2.0.11/go.mod h1:Ormn4YO2MooU40LNFwECoLd8XZFwbRcysET+OAn7FLg=
github.com/pivotal-cf/go-pivnet/v6 v6.0.2/go.mod h1:ymI4gZvp8lf3GNaf1Re+JRV18zU0w8TLBDQB/t8SaFs=
github.com/pivotal-cf/jhanda v0.0.0-20200619200912-8de8eb943a43 h1:SYEUxVbqz3U7pJP/tlaXaD08w0rZVuPvCFRodnw/TLY=
github.com/pivotal-cf/jhanda v0.0.0-20200619200912-8de8eb943a43/go.mod h1:UXciri1Yqno0IdXxEzwMF91nnwYMPoN95goHWxVtWq8=
Expand Down Expand Up @@ -508,8 +503,6 @@ github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX
github.com/shirou/gopsutil v0.0.0-20180927124308-a11c78ba2c13/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v2.20.2+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.20.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.21.1+incompatible h1:2LwXWdbjXwyDgq26Yy/OT4xozlpmssQfy/rtfhWb0bY=
github.com/shirou/gopsutil v3.21.1+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
Expand Down Expand Up @@ -689,8 +682,6 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180709060233-1b2967e3c290/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -918,7 +909,6 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.26/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk=
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
Expand Down
2 changes: 1 addition & 1 deletion internal/acceptance/workflows/baking_a_tile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: As a developer, I want to bake a tile
Given I have a "hello-tile" repository checked out at v0.1.1
And the repository has no fetched releases
When I invoke kiln
| fetch |
| fetch-releases |
| --no-confirm |
| --variable=github_token="${GITHUB_TOKEN}" |
And I invoke kiln
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: As a robot, I want to cache compiled releases
And the environment variable "AWS_SECRET_ACCESS_KEY" is set
And I remove all the objects in the bucket "hello-tile-releases"
And I invoke kiln
| fetch |
| fetch-releases |
| --variable=github_token="${GITHUB_TOKEN}" |
And I invoke kiln
| bake |
Expand All @@ -20,13 +20,13 @@ Feature: As a robot, I want to cache compiled releases
And I add a compiled s3 release-source "hello-tile-releases" to the Kilnfile
And I set the stemcell version in the lock to match the one used for the tile
When I invoke kiln
| cache-compiled-releases |
| cache-releases |
| --upload-target-id=hello-tile-releases |
| --name=hello |
| --variable=github_token="${GITHUB_TOKEN}" |
And the repository has no fetched releases
And I invoke kiln
| fetch |
| fetch-releases |
| --variable=github_token="${GITHUB_TOKEN}" |
And I invoke kiln
| bake |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: As a robot, I want to generate release notes
| 0.1.3 |

When I invoke kiln
| release-notes |
| create-release-notes |
| --release-date=2022-07-27 |
| --github-issue-milestone=Release-2022-001 |
| --update-docs=../scenario/fixtures/release_notes.md.erb |
Expand Down
2 changes: 1 addition & 1 deletion internal/acceptance/workflows/hello-tile
Submodule hello-tile updated 4 files
+0 −1 .gitignore
+3 −0 Kilnfile
+3 −3 Kilnfile.lock
+1 −0 version
1 change: 1 addition & 0 deletions internal/acceptance/workflows/scenario/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func initializeExec(ctx scenarioContext) {
})
ctx.Step(regexp.MustCompile(`^(stdout|stderr|"[^"]*") contains substring: (.*)`), outputContainsSubstring)
ctx.Step(regexp.MustCompile(`^the exit code is (\d+)$`), theExitCodeIs)
ctx.Step(regexp.MustCompile(`^(stdout|stderr|"[^"]*") is valid (json|yaml)$`), outputIsValidEncoding)
}

func InitializeGitHub(ctx *godog.ScenarioContext) { initializeGitHub(ctx) }
Expand Down
3 changes: 3 additions & 0 deletions internal/acceptance/workflows/scenario/step_funcs_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func iRemoveAllTheObjectsInBucket(ctx context.Context, bucket string) error {
listErr := s3Session.ListObjectsV2PagesWithContext(ctx, &s3.ListObjectsV2Input{
Bucket: aws.String(bucket),
}, func(page *s3.ListObjectsV2Output, b bool) bool {
if len(page.Contents) == 0 {
return false
}
var del s3.Delete
for _, o := range page.Contents {
fmt.Printf(" deleting %s\n", aws.StringValue(o.Key))
Expand Down
20 changes: 20 additions & 0 deletions internal/acceptance/workflows/scenario/step_funcs_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package scenario

import (
"context"
"encoding/json"
"fmt"
"strconv"
"strings"

"gopkg.in/yaml.v2"
)

func outputContainsSubstring(ctx context.Context, outputName, substring string) error {
Expand Down Expand Up @@ -38,3 +41,20 @@ func theExitCodeIs(ctx context.Context, expectedCode int) error {
}
return nil
}

func outputIsValidEncoding(ctx context.Context, outputName, encoding string) error {
out, err := output(ctx, outputName)
if err != nil {
return err
}
switch encoding {
case "json":
var raw json.RawMessage
return json.Unmarshal(out.Bytes(), &raw)
case "yaml":
var node interface{}
return yaml.Unmarshal(out.Bytes(), &node)
default:
return fmt.Errorf("unknown encoding: %s", encoding)
}
}
20 changes: 10 additions & 10 deletions internal/acceptance/workflows/scenario/step_funcs_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@ import (
"os/exec"
"testing"

Ω "github.com/onsi/gomega"
. "github.com/onsi/gomega"
)

func Test_outputContainsSubstring(t *testing.T) {
t.Run("stdout contains the string", func(t *testing.T) {
please := Ω.NewWithT(t)
please := NewWithT(t)
ctx := context.Background()
ctx = configureStandardFileDescriptors(ctx)
_, err := runAndLogOnError(ctx, exec.Command("echo", "Hello, world!"), true)
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())

err = outputContainsSubstring(ctx, "stdout", "world")
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())
})

t.Run("stderr contains the string", func(t *testing.T) {
please := Ω.NewWithT(t)
please := NewWithT(t)
ctx := context.Background()
ctx = configureStandardFileDescriptors(ctx)
_, err := runAndLogOnError(ctx, exec.Command("bash", "-c", `echo "Hello, world!" > /dev/stderr`), true)
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())

err = outputContainsSubstring(ctx, "stderr", "world")
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())
})

t.Run("stdout does not contain the substring", func(t *testing.T) {
please := Ω.NewWithT(t)
please := NewWithT(t)
ctx := context.Background()
ctx = configureStandardFileDescriptors(ctx)
_, err := runAndLogOnError(ctx, exec.Command("echo", "Hello, world!"), true)
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())

err = outputContainsSubstring(ctx, "stdout", "banana")
please.Expect(err).To(Ω.MatchError(Ω.Equal("expected substring \"banana\" not found in: \"Hello, world!\"")))
please.Expect(err).To(MatchError(Equal("expected substring \"banana\" not found in: \"Hello, world!\"")))
})
}
12 changes: 6 additions & 6 deletions internal/acceptance/workflows/scenario/step_funcs_github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import (
"context"
"testing"

Ω "github.com/onsi/gomega"
. "github.com/onsi/gomega"
)

func Test_githubRepoHasReleaseWithTag(t *testing.T) {
if isRunningInCI() {
t.Skip("skip this step in CI. GitHub action credentials do not have access to crhntr/hello-release")
}
setup := func(t *testing.T) (context.Context, Ω.Gomega) {
please := Ω.NewWithT(t)
setup := func(t *testing.T) (context.Context, Gomega) {
please := NewWithT(t)
ctx := context.Background()
err := checkoutMain(testTilePath)
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())
ctx = setTileRepoPath(ctx, testTilePath)
ctx, err = loadGithubToken(ctx)
if err != nil {
Expand All @@ -27,12 +27,12 @@ func Test_githubRepoHasReleaseWithTag(t *testing.T) {
t.Run("release exists", func(t *testing.T) {
ctx, please := setup(t)
err := githubRepoHasReleaseWithTag(ctx, "crhntr", "hello-release", "v0.1.5")
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())
})

t.Run("release does not exist", func(t *testing.T) {
ctx, please := setup(t)
err := githubRepoHasReleaseWithTag(ctx, "crhntr", "hello-release", "v99.99.99-banana")
please.Expect(err).To(Ω.HaveOccurred())
please.Expect(err).To(HaveOccurred())
})
}
2 changes: 1 addition & 1 deletion internal/acceptance/workflows/scenario/step_funcs_tile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"gopkg.in/yaml.v2"

"github.com/pivotal-cf/kiln/internal/component"
"github.com/pivotal-cf/kiln/pkg/proofing"
"github.com/pivotal-cf/kiln/internal/proofing"
"github.com/pivotal-cf/kiln/pkg/tile"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package scenario
import (
"context"
"fmt"
"os"
"os/exec"
"strings"

"github.com/cucumber/godog"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"golang.org/x/exp/slices"
"os"
"os/exec"
"strings"

"github.com/pivotal-cf/kiln/internal/component"
"github.com/pivotal-cf/kiln/pkg/cargo"
Expand Down
12 changes: 6 additions & 6 deletions internal/acceptance/workflows/scenario/step_funcs_tile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ import (
"context"
"testing"

Ω "github.com/onsi/gomega"
. "github.com/onsi/gomega"
)

func Test_theLockSpecifiesVersionForRelease(t *testing.T) {
setup := func(t *testing.T) (context.Context, Ω.Gomega) {
please := Ω.NewWithT(t)
setup := func(t *testing.T) (context.Context, Gomega) {
please := NewWithT(t)
ctx := context.Background()
err := checkoutMain(testTilePath)
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())
ctx = setTileRepoPath(ctx, testTilePath)
return ctx, please
}

t.Run("it matches the release version", func(t *testing.T) {
ctx, please := setup(t)
err := theLockSpecifiesVersionForRelease(ctx, "0.1.5", "hello-release")
please.Expect(err).NotTo(Ω.HaveOccurred())
please.Expect(err).NotTo(HaveOccurred())
})

t.Run("it does not match the release version", func(t *testing.T) {
ctx, please := setup(t)
err := theLockSpecifiesVersionForRelease(ctx, "9000.0.0", "hello-release")
please.Expect(err).To(Ω.HaveOccurred())
please.Expect(err).To(HaveOccurred())
})
}
7 changes: 4 additions & 3 deletions internal/acceptance/workflows/updating_stemcell.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ Feature: As a dependabot, I want to update a stemcell

Scenario: Find the new stemcell
Given I have a "hello-tile" repository checked out at v0.1.5
And TanzuNetwork has product "stemcells-ubuntu-xenial" with version "621.296"
And the environment variable "GITHUB_TOKEN" is set
When I invoke kiln
| find-stemcell-version |
| --variable=github_token="${GITHUB_TOKEN}" |
Then stdout contains substring: "621.296"
Then stdout is valid json

Scenario: Update the stemcell
Given I have a "hello-tile" repository checked out at v0.1.5
And TanzuNetwork has product "stemcells-ubuntu-xenial" with version "621.296"
And the environment variable "GITHUB_TOKEN" is set
And TanzuNetwork has product "stemcells-ubuntu-xenial" with version "621.280"
And the Kilnfile.lock specifies version "621.0" for the stemcell
When I invoke kiln
| update-stemcell |
Expand Down
Loading