Skip to content

Commit 553793d

Browse files
committed
test: improve bumpver testing
1 parent 78f325b commit 553793d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

internal/cli/bumpver.go

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package cli
22

33
import (
4+
"errors"
5+
"fmt"
6+
47
"github.com/Masterminds/semver/v3"
58
"github.com/futurice/jalapeno/internal/cli/option"
69
"github.com/futurice/jalapeno/pkg/recipe"
@@ -92,6 +95,9 @@ func runBumpVer(cmd *cobra.Command, opts bumpVerOpts) error {
9295
} else {
9396
optVer, err := semver.NewVersion(opts.RecipeVersion)
9497
if err != nil {
98+
if errors.Is(err, semver.ErrInvalidSemVer) {
99+
return fmt.Errorf("provided version is not valid semver: %s", opts.RecipeVersion)
100+
}
95101
return err
96102
}
97103

test/features/bumpver.feature

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ Feature: Bump recipe version and write changelog
22

33
Scenario: Directly bump version
44
Given a recipe "foo"
5-
When I bump recipe "foo" version to "v0.0.2" with message "Test"
5+
When I bump recipe "foo" version to "v0.0.2" with message "Test"
66
Then recipe "foo" has version "v0.0.2"
7+
And CLI produced an output "bumped version: v0.0.1 => v0.0.2"
78
And recipe "foo" has changelog message "Test"
89

910
Scenario: Command inits changelog
1011
Given a recipe "foo"
11-
When I bump recipe "foo" version to "v0.0.2" with message "Test"
12+
When I bump recipe "foo" version to "v0.0.2" with message "Test"
1213
Then recipe "foo" contains changelog with 2 entries
14+
And CLI produced an output "bumped version: v0.0.1 => v0.0.2"
1315
And first entry in recipe "foo" changelog has message "Init version"
1416

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

0 commit comments

Comments
 (0)