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%.
31 lines
896 B
Go
31 lines
896 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// TestRunCLIDispatch covers the subset of runCLI's switch that has no side
|
|
// effects (no filesystem/network touched) - the actual subcommand bodies
|
|
// (download/install/env) get their own focused tests.
|
|
func TestRunCLIDispatch(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
args []string
|
|
want int
|
|
}{
|
|
{"no args prints usage", nil, 1},
|
|
{"unknown subcommand", []string{"frobnicate"}, 1},
|
|
{"help long", []string{"--help"}, 0},
|
|
{"help short flag", []string{"-h"}, 0},
|
|
{"help word", []string{"help"}, 0},
|
|
{"help alias", []string{"h"}, 0},
|
|
{"version word", []string{"version"}, 0},
|
|
{"version alias", []string{"v"}, 0},
|
|
{"version flag", []string{"--version"}, 0},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := runCLI(tc.args); got != tc.want {
|
|
t.Errorf("runCLI(%v) = %d, want %d", tc.args, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|