Modernizes several `internal/*` packages under the Go proxy, replaces
third-party forks with standard-library primitives, and brings the
test suite from near-zero to high coverage across the touched packages.
Package changes
- **`internal/errors`** — Rewrites the `pkg/errors` fork as a thin
wrapper
over stdlib `errors`. A single `withStack` struct captures stack
traces via `runtime.Callers`; `fmt.Errorf("%w", ...)` handles all
message wrapping. Restores `errors.Is`/`As`/`Unwrap` chain traversal
(silently broken in the fork) and deletes ~190 lines of stack/frame
formatting. `Is`, `As`, `Unwrap`, and `Join` are re-exported so
callers need a single import.
- **`internal/logger`** — Swaps stdlib `log.Logger` for `log/slog` JSON
handlers with UTC timestamps and custom level labels (`verb`, `debug`,
`warn`, `error`). Hides `withContextID` (no external callers).
- **`internal/sync`** — Converts `Map[K, V]` from a concrete struct to
an interface with a `NewMap` constructor for testability.
- **`internal/signal`** — Adds `signalNotify` / `osExit` indirections so
`InstallSignals` and `InstallForceQuit` can be exercised without real
OS signals or process termination.
- **`internal/utils`** — Drops deprecated `io/ioutil` and the stdlib
`errors` alias (the internal `errors` package re-exports what's
needed).
- **`internal/version`** — No code changes; fully covered by new tests.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
35 lines
780 B
Go
35 lines
780 B
Go
// Copyright (c) 2026 Winlin
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
package version
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestVersionComponents(t *testing.T) {
|
|
if got := VersionMajor(); got != 7 {
|
|
t.Fatalf("VersionMajor = %d, want 7", got)
|
|
}
|
|
if got := VersionMinor(); got != 0 {
|
|
t.Fatalf("VersionMinor = %d, want 0", got)
|
|
}
|
|
if got := VersionRevision(); got <= 0 {
|
|
t.Fatalf("VersionRevision = %d, want > 0", got)
|
|
}
|
|
}
|
|
|
|
func TestVersion_FormatsMajorMinorRevision(t *testing.T) {
|
|
want := fmt.Sprintf("%d.%d.%d", VersionMajor(), VersionMinor(), VersionRevision())
|
|
if got := Version(); got != want {
|
|
t.Fatalf("Version = %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
func TestSignature(t *testing.T) {
|
|
if got := Signature(); got != "SRSX" {
|
|
t.Fatalf("Signature = %q, want SRSX", got)
|
|
}
|
|
}
|