Files
releaser/internal/version/version_test.go
T
k3nny 5af107b06d
ci / vet, staticcheck, test, build (push) Successful in 3m54s
release / Build and publish release (push) Successful in 4m11s
feat(releaser): release v1.4.0 — GitHub, SSH agent, configurable bumps
- GitHub release support: internal/ghclient (no SDK, minimal HTTP client);
  GITHUB_TOKEN env var; github.token/github.repo config; GitHub takes
  precedence over GitLab when both are configured; publisher interface
  (releasePublisher) in cmd/main.go makes providers interchangeable
- SSH agent push: gitutil.Push() now tries gitssh.NewSSHAgentAuth for
  git@/ssh:// remotes before falling back to the system git binary
- --release-env-file flag: override dotenv artifact path; pass "" to disable
- git.releasable_types config: filter which commit types trigger a bump
  (defaults to fix, feat, breaking); useful for maintenance branches
- commits.Group(), ExtractSubject(), ReleasableSet() exported helpers:
  notes.go and changelog.go now delegate to these instead of duplicating
- CHANGELOG deduplication guard: changelog.Update() is idempotent — skips
  write if ## [version] section already exists
- Always load config sources: LoadWithSources() called unconditionally;
  removes the dual config path that previously only tracked sources in
  --verbose mode
- .releaser.gitlab-ci.yml: adds artifacts: reports: dotenv: release.env

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-11 00:15:09 +02:00

74 lines
1.7 KiB
Go

package version
import (
"testing"
"git.k3nny.fr/releaser/internal/commits"
)
func TestNext(t *testing.T) {
cases := []struct {
desc string
major, minor int
currentPatch int
types []commits.Type
want string
wantOk bool
}{
{
desc: "first release with feat",
major: 1, minor: 2, currentPatch: -1,
types: []commits.Type{commits.TypeFeat},
want: "1.2.0",
wantOk: true,
},
{
desc: "bump from patch 3",
major: 1, minor: 2, currentPatch: 3,
types: []commits.Type{commits.TypeFix},
want: "1.2.4",
wantOk: true,
},
{
desc: "breaking change still bumps patch on release branch",
major: 2, minor: 0, currentPatch: 1,
types: []commits.Type{commits.TypeBreaking},
want: "2.0.2",
wantOk: true,
},
{
desc: "only chore commits — nothing to release",
major: 1, minor: 2, currentPatch: 5,
types: []commits.Type{commits.TypeNone, commits.TypeNone},
want: "",
wantOk: false,
},
{
desc: "no commits at all",
major: 1, minor: 2, currentPatch: 0,
types: nil,
want: "",
wantOk: false,
},
{
desc: "one releasable commit among chores",
major: 1, minor: 3, currentPatch: 7,
types: []commits.Type{commits.TypeNone, commits.TypeFix, commits.TypeNone},
want: "1.3.8",
wantOk: true,
},
}
for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
got, ok := Next(c.major, c.minor, c.currentPatch, c.types, nil)
if ok != c.wantOk {
t.Errorf("ok=%v, want %v", ok, c.wantOk)
}
if got != c.want {
t.Errorf("got %q, want %q", got, c.want)
}
})
}
}