mirror of
https://github.com/Cheviiot/Vintner.git
synced 2026-08-03 15:57:24 +00:00
Both were at 0% coverage. Focused on what's safely testable without touching the network or filesystem: flag validation (--architecture/ --host-arch, the same guard added in the stability pass), subcommand dispatch and aliases, help/usage error paths, and - for i18n - full language-detection table coverage plus a completeness check that every catalog key has both an EN and RU entry (an English-only or Russian-only entry would silently degrade rather than fail loudly, so this is worth locking in). cmd/vintner: 0% -> 28.8%, i18n: 0% -> 94.1%.
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// TestRunDownloadRejectsInvalidArchFlags exercises the validation added
|
|
// after the flags are parsed, which must reject typos before runDownload
|
|
// gets anywhere near the network (FetchChannelManifest) - these tests would
|
|
// hang/fail on network access if that ordering ever regressed.
|
|
func TestRunDownloadRejectsInvalidArchFlags(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
args []string
|
|
}{
|
|
{"bad architecture", []string{"--architecture", "x866"}},
|
|
{"bad architecture, valid mixed with invalid", []string{"--architecture", "x64", "--architecture", "sparc"}},
|
|
{"bad host-arch", []string{"--host-arch", "sparc"}},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if code := runDownload(tc.args); code != 2 {
|
|
t.Errorf("runDownload(%v) = %d, want 2", tc.args, code)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestValidArchitectureSets(t *testing.T) {
|
|
for _, a := range []string{"x86", "x64", "arm", "arm64", "host"} {
|
|
if !validArchitectures[a] {
|
|
t.Errorf("validArchitectures[%q] = false, want true", a)
|
|
}
|
|
}
|
|
for _, a := range []string{"x86", "x64", "arm64"} {
|
|
if !validHostArchs[a] {
|
|
t.Errorf("validHostArchs[%q] = false, want true", a)
|
|
}
|
|
}
|
|
if validHostArchs["arm"] {
|
|
t.Error(`validHostArchs["arm"] = true, want false (no 32-bit ARM host toolchain exists)`)
|
|
}
|
|
}
|