< Summary - Neospec Coverage

Information
Class: Platform
Assembly: domain
File(s): /home/runner/work/neospec/neospec/internal/domain/platform.go
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 73
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
String0%00100%

File(s)

/home/runner/work/neospec/neospec/internal/domain/platform.go

#LineLine coverage
 1// Package domain contains the core data types and pure business logic for neospec.
 2// Nothing in this package performs I/O or depends on external packages — it is
 3// the stable heart of the application that all other packages point toward.
 4package domain
 5
 6import (
 7  "fmt"
 8  "runtime"
 9)
 10
 11// OS represents a target operating system.
 12type OS string
 13
 14// Supported operating systems.
 15const (
 16  OSLinux   OS = "linux"
 17  OSDarwin  OS = "darwin"
 18  OSWindows OS = "windows"
 19)
 20
 21// Arch represents a CPU architecture.
 22type Arch string
 23
 24// Supported CPU architectures.
 25const (
 26  ArchAMD64 Arch = "x86_64"
 27  ArchARM64 Arch = "arm64"
 28)
 29
 30// Platform combines an OS and architecture for use in Neovim release asset selection.
 31type Platform struct {
 32  OS   OS
 33  Arch Arch
 34}
 35
 36// CurrentPlatform returns the Platform for the running process.
 37func CurrentPlatform() (Platform, error) {
 38  return parsePlatform(runtime.GOOS, runtime.GOARCH)
 39}
 40
 41// parsePlatform maps a GOOS/GOARCH pair to a Platform. It is the testable
 42// inner function for CurrentPlatform — callers that need to simulate unusual
 43// or unsupported platforms can call it directly in white-box tests.
 44func parsePlatform(goos, goarch string) (Platform, error) {
 45  var os OS
 46  switch goos {
 47  case "linux":
 48    os = OSLinux
 49  case "darwin":
 50    os = OSDarwin
 51  case "windows":
 52    os = OSWindows
 53  default:
 54    return Platform{}, fmt.Errorf("unsupported OS: %s", goos)
 55  }
 56
 57  var arch Arch
 58  switch goarch {
 59  case "amd64":
 60    arch = ArchAMD64
 61  case "arm64":
 62    arch = ArchARM64
 63  default:
 64    return Platform{}, fmt.Errorf("unsupported architecture: %s", goarch)
 65  }
 66
 67  return Platform{OS: os, Arch: arch}, nil
 68}
 69
 70// String returns a human-readable platform string, e.g. "linux/x86_64".
 1071func (p Platform) String() string {
 1072  return fmt.Sprintf("%s/%s", p.OS, p.Arch)
 1073}

Methods/Properties

String