New init command writes a default config file with commented explanations for every setting. Uses XDG config directory via github.com/adrg/xdg for platform-appropriate paths: macOS: ~/Library/Application Support/vaultik/config.yml Linux: ~/.config/vaultik/config.yml root: /etc/vaultik/config.yml Config resolution now searches the XDG path before /etc/vaultik/. Refuses to overwrite an existing file. Created with 0600 permissions. README quickstart rewritten as a single copy-pasteable shell block walking through install, keygen, init, edit, first backup, verify, and cron setup.
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// TestCLIEntry ensures the CLI can be imported and basic initialization works
|
|
func TestCLIEntry(t *testing.T) {
|
|
// This test primarily serves as a compilation test
|
|
// to ensure all imports resolve correctly
|
|
cmd := 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{"init", "snapshot", "store", "restore", "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", "cleanup"}
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|