diff --git a/internal/acceptance/workflows/scenario/initialize.go b/internal/acceptance/workflows/scenario/initialize.go index b1df2391..fa9f5eac 100644 --- a/internal/acceptance/workflows/scenario/initialize.go +++ b/internal/acceptance/workflows/scenario/initialize.go @@ -55,6 +55,8 @@ func InitializeKiln(ctx *godog.ScenarioContext) { initializeKiln(ctx) } func initializeKiln(ctx scenarioContext) { ctx.Step(regexp.MustCompile(`^I invoke kiln$`), iInvokeKiln) ctx.Step(regexp.MustCompile(`^I try to invoke kiln$`), iTryToInvokeKiln) + ctx.Step(regexp.MustCompile(`^the "([^"]*)" release tarball exists$`), theReleaseTarballExists) + ctx.Step(regexp.MustCompile(`^the "([^"]*)" release tarball does not exist$`), theReleaseTarballDoesNotExist) } func InitializeRegex(ctx *godog.ScenarioContext) { initializeRegex(ctx) } diff --git a/internal/acceptance/workflows/scenario/step_funcs_kiln.go b/internal/acceptance/workflows/scenario/step_funcs_kiln.go index 5e9cad2b..73931d1a 100644 --- a/internal/acceptance/workflows/scenario/step_funcs_kiln.go +++ b/internal/acceptance/workflows/scenario/step_funcs_kiln.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "path/filepath" "regexp" "strings" @@ -18,6 +19,36 @@ func iTryToInvokeKiln(ctx context.Context, table *godog.Table) (context.Context, return invokeKiln(ctx, false, argsFromTable(table)...) } +func theReleaseTarballExists(ctx context.Context, tarballName string) error { + tileDir, err := tileRepoPath(ctx) + if err != nil { + return fmt.Errorf("failed to get tile repo path: %w", err) + } + + releasePath := filepath.Join(tileDir, "releases", tarballName) + _, err = os.Stat(releasePath) + return err +} + +func theReleaseTarballDoesNotExist(ctx context.Context, tarballName string) error { + tileDir, err := tileRepoPath(ctx) + if err != nil { + return fmt.Errorf("failed to get tile repo path: %w", err) + } + + releasePath := filepath.Join(tileDir, "releases", tarballName) + _, err = os.Stat(releasePath) + if err == nil { + return fmt.Errorf("release tarball %q exists", tarballName) + } + + if !os.IsNotExist(err) { + return err + } + + return nil +} + func kilnValidateSucceeds(ctx context.Context) (context.Context, error) { return invokeKiln(ctx, true, "validate", "--variable=github_access_token=banana") } diff --git a/internal/acceptance/workflows/updating_releases.feature b/internal/acceptance/workflows/updating_releases.feature index ac2bef48..6d08fc16 100644 --- a/internal/acceptance/workflows/updating_releases.feature +++ b/internal/acceptance/workflows/updating_releases.feature @@ -11,6 +11,7 @@ Feature: As a dependabot, I want to update a BOSH Release Scenario: Find a version on bosh.io Given I have a tile source directory "testdata/tiles/v2" + And the repository has no fetched releases And I set the version constraint to "1.1.18" for release "bpm" When I invoke kiln | find-release-version | @@ -18,15 +19,30 @@ Feature: As a dependabot, I want to update a BOSH Release | --variable=github_access_token="${GITHUB_ACCESS_TOKEN}" | Then stdout contains substring: "1.1.18" - Scenario: Update a component to a new release + Scenario: Update a component to a new release with download Given I have a tile source directory "testdata/tiles/v2" + And the repository has no fetched releases And the Kilnfile.lock specifies version "0.2.3" for release "hello-release" - And GitHub repository "crhntr/hello-release" has release with tag "v0.2.3" + And GitHub repository "crhntr/hello-release" has release with tag "0.3.0" When I invoke kiln | update-release | | --name=hello-release | - | --version=v0.2.3 | + | --version=0.3.0 | + | --variable=github_access_token="${GITHUB_ACCESS_TOKEN}" | + Then the Kilnfile.lock specifies version "0.3.0" for release "hello-release" + And kiln validate succeeds + And the "hello-release-0.3.0.tgz" release tarball exists + + Scenario: Update a component to a new release without download + Given I have a tile source directory "testdata/tiles/v2" + And the repository has no fetched releases + And the Kilnfile.lock specifies version "1.2.12" for release "bpm" + When I invoke kiln + | update-release | + | --name=bpm | + | --version=1.2.13 | | --without-download | | --variable=github_access_token="${GITHUB_ACCESS_TOKEN}" | - Then the Kilnfile.lock specifies version "0.2.3" for release "hello-release" + Then the Kilnfile.lock specifies version "1.2.13" for release "bpm" And kiln validate succeeds + And the "bpm-1.2.13.tgz" release tarball does not exist diff --git a/internal/acceptance/workflows/updating_stemcell.feature b/internal/acceptance/workflows/updating_stemcell.feature index c206e208..29000e79 100644 --- a/internal/acceptance/workflows/updating_stemcell.feature +++ b/internal/acceptance/workflows/updating_stemcell.feature @@ -13,12 +13,45 @@ Feature: As a dependabot, I want to update a stemcell | --variable=github_access_token="${GITHUB_ACCESS_TOKEN}" | Then stdout contains substring: "1.340" - Scenario: Update the stemcell + Scenario: Update the stemcell with download Given I have a tile source directory "testdata/tiles/v2" + And the repository has no fetched releases And TanzuNetwork has product "stemcells-ubuntu-jammy" with version "1.340" And "Kilnfile.lock" contains substring: version: "1.329" When I invoke kiln | update-stemcell | - | --version=1.340 | + | --version=1.340 | | --variable=github_access_token="${GITHUB_ACCESS_TOKEN}" | Then "Kilnfile.lock" contains substring: version: "1.340" + And the Kilnfile.lock specifies version "0.2.3" for release "hello-release" + And the "bpm-1.2.12.tgz" release tarball exists + And the "hello-release-0.2.3.tgz" release tarball exists + + Scenario: Update the stemcell without download + Given I have a tile source directory "testdata/tiles/v2" + And the repository has no fetched releases + And TanzuNetwork has product "stemcells-ubuntu-jammy" with version "1.340" + And "Kilnfile.lock" contains substring: version: "1.329" + When I invoke kiln + | update-stemcell | + | --version=1.340 | + | --without-download | + | --variable=github_access_token="${GITHUB_ACCESS_TOKEN}" | + Then "Kilnfile.lock" contains substring: version: "1.340" + And the Kilnfile.lock specifies version "0.2.3" for release "hello-release" + And the "bpm-1.2.12.tgz" release tarball does not exist + And the "hello-release-0.2.3.tgz" release tarball does not exist + + Scenario: Update the stemcell with release updates + Given I have a tile source directory "testdata/tiles/v2" + And the repository has no fetched releases + And TanzuNetwork has product "stemcells-ubuntu-jammy" with version "1.340" + And "Kilnfile.lock" contains substring: version: "1.329" + When I invoke kiln + | update-stemcell | + | --version=1.340 | + | --update-releases | + | --variable=github_access_token="${GITHUB_ACCESS_TOKEN}" | + Then "Kilnfile.lock" contains substring: version: "1.340" + And the Kilnfile.lock specifies version "0.3.0" for release "hello-release" + And the "hello-release-0.3.0.tgz" release tarball exists