< Summary - go-semantic-release Coverage

Information
Line coverage
100%
Covered lines: 37
Uncovered lines: 0
Coverable lines: 37
Total lines: 75
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Verify0%00100%
checkBranch0%00100%
checkGitHub0%00100%

File(s)

/home/runner/work/go-semantic-release/go-semantic-release/internal/app/verify_conditions.go

#LineLine coverage
 1package app
 2
 3import (
 4  "context"
 5  "fmt"
 6  "strings"
 7
 8  "github.com/jedi-knights/go-semantic-release/internal/domain"
 9  "github.com/jedi-knights/go-semantic-release/internal/ports"
 10)
 11
 12// ConditionVerifier checks that all prerequisites for a release are met.
 13type ConditionVerifier struct {
 14  git    ports.GitRepository
 15  config domain.Config
 16  logger ports.Logger
 17}
 18
 19// NewConditionVerifier creates a condition verifier.
 20func NewConditionVerifier(git ports.GitRepository, config domain.Config, logger ports.Logger) *ConditionVerifier {
 21  return &ConditionVerifier{git: git, config: config, logger: logger}
 22}
 23
 24// VerificationResult captures the outcome of condition checks.
 25type VerificationResult struct {
 26  Passed   bool
 27  Failures []string
 28}
 29
 30// Verify checks all release conditions.
 731func (v *ConditionVerifier) Verify(ctx context.Context) (*VerificationResult, error) {
 732  result := &VerificationResult{Passed: true}
 733
 734  branch, err := v.git.CurrentBranch(ctx)
 135  if err != nil {
 136    return nil, fmt.Errorf("getting current branch: %w", err)
 137  }
 38
 639  v.checkBranch(branch, result)
 640  v.checkGitHub(result)
 641
 642  return result, nil
 43}
 44
 645func (v *ConditionVerifier) checkBranch(branch string, result *VerificationResult) {
 646  policy := domain.FindBranchPolicy(v.config.Branches, branch)
 147  if policy == nil {
 148    result.Passed = false
 149    result.Failures = append(result.Failures,
 150      fmt.Sprintf("branch %q is not configured for releases", branch))
 151  }
 52}
 53
 654func (v *ConditionVerifier) checkGitHub(result *VerificationResult) {
 355  if !v.config.GitHub.CreateRelease {
 356    return
 357  }
 58
 359  var missing []string
 260  if v.config.GitHub.Owner == "" {
 261    missing = append(missing, "github.owner")
 262  }
 163  if v.config.GitHub.Repo == "" {
 164    missing = append(missing, "github.repo")
 165  }
 266  if v.config.GitHub.Token == "" {
 267    missing = append(missing, "github.token (or SEMANTIC_RELEASE_GITHUB_TOKEN)")
 268  }
 69
 370  if len(missing) > 0 {
 371    result.Passed = false
 372    result.Failures = append(result.Failures,
 373      fmt.Sprintf("missing GitHub config: %s", strings.Join(missing, ", ")))
 374  }
 75}

Methods/Properties

Verify
checkBranch
checkGitHub