Fix every finding surfaced by the canonical .golangci.yml with golangci-lint v2.12.2 (refs #61), behavior-preserving throughout: - err113: dynamic errors replaced with package-level sentinels and %w wrapping; direct comparisons converted to errors.Is - goprintffuncname: printf-style helpers renamed with an f suffix (ui.Writer message methods, cli.ReportErrorf, database.Fatalf, vaultik stdoutf) and all call sites updated - revive: stuttering type names renamed (blob.Handler, blob.WithReader, blob.ChunkPosition, storage.URL, storage.Info), doc comments added, unused parameters blanked, package comments added - contextcheck/noctx: ctx threaded through blob.Packer (AddChunk/Flush/FinalizeBlob/PackChunks) and scanner call sites; context-aware exec and sql variants used - funlen/cyclop/gocognit/nestif/dupl: oversized or duplicated functions split into focused helpers across production and test code - paralleltest/tparallel/thelper/usetesting/testpackage: tests parallelized where safe (global log.Initialize kept in the serial phase), helpers marked, t.TempDir adopted, external test packages where only exported API is used - gosec: integer conversions clamped or justified, header timeouts added, remaining findings suppressed with per-site justifications - mnd/goconst/lll/wsl_v5/nlreturn/noinlineerr/errcheck and other mechanical findings fixed directly Remove the deprecated log.LogOptions alias (callers migrated to log.Options). make check is green.
70 lines
1.5 KiB
Go
70 lines
1.5 KiB
Go
package cli_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"sneak.berlin/go/vaultik/internal/cli"
|
|
)
|
|
|
|
// TestCLIEntry ensures the CLI can be imported and basic initialization works
|
|
func TestCLIEntry(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
// This test primarily serves as a compilation test
|
|
// to ensure all imports resolve correctly
|
|
cmd := cli.NewRootCommand()
|
|
if cmd == nil {
|
|
t.Fatal("NewRootCommand() returned nil")
|
|
}
|
|
|
|
if cmd.Use != "vaultik" {
|
|
t.Errorf("Expected command use to be 'vaultik', got '%s'", cmd.Use)
|
|
}
|
|
|
|
// Verify all subcommands are registered
|
|
expectedCommands := []string{
|
|
"config", "snapshot", "prune", "info", "version", "remote", "database",
|
|
}
|
|
for _, expected := range expectedCommands {
|
|
found := false
|
|
|
|
for _, cmd := range cmd.Commands() {
|
|
if cmd.Use == expected || cmd.Name() == expected {
|
|
found = true
|
|
|
|
break
|
|
}
|
|
}
|
|
|
|
if !found {
|
|
t.Errorf("Expected command '%s' not found", expected)
|
|
}
|
|
}
|
|
|
|
// Verify snapshot command has subcommands
|
|
snapshotCmd, _, err := cmd.Find([]string{"snapshot"})
|
|
if err != nil {
|
|
t.Errorf("Failed to find snapshot command: %v", err)
|
|
} else {
|
|
// Check snapshot subcommands
|
|
expectedSubCommands := []string{
|
|
"create", "list", "purge", "verify", "remove", "restore",
|
|
}
|
|
for _, expected := range expectedSubCommands {
|
|
found := false
|
|
|
|
for _, subcmd := range snapshotCmd.Commands() {
|
|
if subcmd.Use == expected || subcmd.Name() == expected {
|
|
found = true
|
|
|
|
break
|
|
}
|
|
}
|
|
|
|
if !found {
|
|
t.Errorf("Expected snapshot subcommand '%s' not found", expected)
|
|
}
|
|
}
|
|
}
|
|
}
|