Skip to content

Commit

Permalink
test: improve bumpver testing
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Oct 31, 2024
1 parent 78f325b commit 553793d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions internal/cli/bumpver.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cli

import (
"errors"
"fmt"

"github.com/Masterminds/semver/v3"
"github.com/futurice/jalapeno/internal/cli/option"
"github.com/futurice/jalapeno/pkg/recipe"
Expand Down Expand Up @@ -92,6 +95,9 @@ func runBumpVer(cmd *cobra.Command, opts bumpVerOpts) error {
} else {
optVer, err := semver.NewVersion(opts.RecipeVersion)
if err != nil {
if errors.Is(err, semver.ErrInvalidSemVer) {
return fmt.Errorf("provided version is not valid semver: %s", opts.RecipeVersion)
}
return err
}

Expand Down
10 changes: 6 additions & 4 deletions test/features/bumpver.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ Feature: Bump recipe version and write changelog

Scenario: Directly bump version
Given a recipe "foo"
When I bump recipe "foo" version to "v0.0.2" with message "Test"
When I bump recipe "foo" version to "v0.0.2" with message "Test"
Then recipe "foo" has version "v0.0.2"
And CLI produced an output "bumped version: v0.0.1 => v0.0.2"
And recipe "foo" has changelog message "Test"

Scenario: Command inits changelog
Given a recipe "foo"
When I bump recipe "foo" version to "v0.0.2" with message "Test"
When I bump recipe "foo" version to "v0.0.2" with message "Test"
Then recipe "foo" contains changelog with 2 entries
And CLI produced an output "bumped version: v0.0.1 => v0.0.2"
And first entry in recipe "foo" changelog has message "Init version"

Scenario: Invalid semantic version
Given a recipe "foo"
When I bump recipe "foo" version to "bar" with message "Test"
Then CLI produced an error "Error: Invalid Semantic Version"
When I bump recipe "foo" version to "no-valid-semver" with message "Test"
Then CLI produced an error "Error: provided version is not valid semver"

0 comments on commit 553793d

Please sign in to comment.