< Summary - Neospec Coverage

Information
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 54
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
Ensure0%00100%

File(s)

/home/runner/work/neospec/neospec/internal/adapters/neovim/provider.go

#LineLine coverage
 1// Package neovim implements ports.NeovimProvider. It downloads Neovim release
 2// archives from GitHub, caches the extracted binary on disk, and returns the
 3// path to the binary on each call to Ensure.
 4package neovim
 5
 6import (
 7  "context"
 8  "fmt"
 9  "path/filepath"
 10
 11  "github.com/jedi-knights/neospec/internal/domain"
 12)
 13
 14// Provider satisfies ports.NeovimProvider.
 15type Provider struct {
 16  cache      *Cache
 17  downloader *Downloader
 18}
 19
 20// NewProvider creates a Provider that stores binaries under cacheDir.
 21func NewProvider(cacheDir string) *Provider {
 22  return &Provider{
 23    cache:      NewCache(cacheDir),
 24    downloader: NewDownloader(),
 25  }
 26}
 27
 28// Ensure returns the path to an nvim binary of the requested version.
 29// It checks the local cache first; on a cache miss it downloads and extracts
 30// the archive, then caches the result.
 531func (p *Provider) Ensure(ctx context.Context, version domain.Version, platform domain.Platform) (string, error) {
 532  binaryPath, ok := p.cache.Lookup(version, platform)
 133  if ok {
 134    return binaryPath, nil
 135  }
 36
 437  assetName := version.AssetName(platform)
 138  if assetName == "" {
 139    return "", fmt.Errorf("unsupported platform: %s", platform)
 140  }
 41
 342  archivePath := filepath.Join(p.cache.VersionDir(version, platform), assetName)
 343
 144  if err := p.downloader.Download(ctx, version, platform, archivePath); err != nil {
 145    return "", fmt.Errorf("downloading neovim %s for %s: %w", version, platform, err)
 146  }
 47
 248  binaryPath, err := p.cache.Extract(version, platform, archivePath)
 149  if err != nil {
 150    return "", fmt.Errorf("extracting neovim archive: %w", err)
 151  }
 52
 153  return binaryPath, nil
 54}

Methods/Properties

Ensure