mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
- Add brew package for Homebrew support on macOS and Linux - Implement NameNormalizer interface (NormalizeName, ParseArch) for all providers - Add darwin platform detection with Homebrew as default - Consolidate capabilities by removing separate *_linux.go/*_other.go files - Update tests for new capability expectations - Add comprehensive tests for AUR and brew providers - Update README with capability matrix and modern Target API usage 💘 Generated with Crush Assisted-by: AWS Claude Opus 4.5 via Crush <crush@charm.land>
66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
//go:build linux
|
|
|
|
package pacman
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gogrlx/snack"
|
|
)
|
|
|
|
func TestBuildArgs(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
base []string
|
|
opts snack.Options
|
|
wantCmd string
|
|
wantArgs []string
|
|
}{
|
|
{
|
|
name: "basic",
|
|
base: []string{"-S", "vim"},
|
|
opts: snack.Options{},
|
|
wantCmd: "pacman",
|
|
wantArgs: []string{"-S", "vim"},
|
|
},
|
|
{
|
|
name: "with sudo",
|
|
base: []string{"-S", "vim"},
|
|
opts: snack.Options{Sudo: true},
|
|
wantCmd: "sudo",
|
|
wantArgs: []string{"pacman", "-S", "vim"},
|
|
},
|
|
{
|
|
name: "with root and noconfirm",
|
|
base: []string{"-S", "vim"},
|
|
opts: snack.Options{Root: "/mnt", AssumeYes: true},
|
|
wantCmd: "pacman",
|
|
wantArgs: []string{"-r", "/mnt", "-S", "vim", "--noconfirm"},
|
|
},
|
|
{
|
|
name: "dry run",
|
|
base: []string{"-S", "vim"},
|
|
opts: snack.Options{DryRun: true},
|
|
wantCmd: "pacman",
|
|
wantArgs: []string{"-S", "vim", "--print"},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
cmd, args := buildArgs(tt.base, tt.opts)
|
|
if cmd != tt.wantCmd {
|
|
t.Errorf("cmd = %q, want %q", cmd, tt.wantCmd)
|
|
}
|
|
if len(args) != len(tt.wantArgs) {
|
|
t.Fatalf("args = %v, want %v", args, tt.wantArgs)
|
|
}
|
|
for i := range args {
|
|
if args[i] != tt.wantArgs[i] {
|
|
t.Errorf("args[%d] = %q, want %q", i, args[i], tt.wantArgs[i])
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|