Skip to content

Commit

Permalink
Add acceptance test coverage for new features
Browse files Browse the repository at this point in the history
* update-release --without-download
* update-stemcell --without-download
* updating_stemcell --update-releases
  • Loading branch information
davewalter committed Jan 17, 2025
1 parent c300bad commit 186630c
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 6 deletions.
2 changes: 2 additions & 0 deletions internal/acceptance/workflows/scenario/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
31 changes: 31 additions & 0 deletions internal/acceptance/workflows/scenario/step_funcs_kiln.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"path/filepath"
"regexp"
"strings"

Expand All @@ -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")
}
Expand Down
24 changes: 20 additions & 4 deletions internal/acceptance/workflows/updating_releases.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,38 @@ 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 |
| --release=bpm |
| --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
37 changes: 35 additions & 2 deletions internal/acceptance/workflows/updating_stemcell.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 186630c

Please sign in to comment.