mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
- Replace shell git clone with go-git for cloning/pulling PKGBUILDs - Add rpcInfoMulti for batch AUR queries (single HTTP request) - Add functional options: WithBuildDir, WithMakepkgFlags - Implement proper remove/purge via pacman -R/-Rns - Fix temp directory leak: buildPackage returns cleanup path - Remove NameNormalizer (AUR names are plain identifiers) - Update README capability matrix - Remove duplicate platform stubs (flatpak, ports)
66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
package aur
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParsePackageList(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
expect int
|
|
}{
|
|
{
|
|
name: "empty",
|
|
input: "",
|
|
expect: 0,
|
|
},
|
|
{
|
|
name: "single package",
|
|
input: "yay 12.5.7-1\n",
|
|
expect: 1,
|
|
},
|
|
{
|
|
name: "multiple packages",
|
|
input: "yay 12.5.7-1\nparu 2.0.4-1\naur-helper 1.0-1\n",
|
|
expect: 3,
|
|
},
|
|
{
|
|
name: "trailing whitespace",
|
|
input: "yay 12.5.7-1 \n paru 2.0.4-1\n\n",
|
|
expect: 2,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
pkgs := parsePackageList(tt.input)
|
|
assert.Len(t, pkgs, tt.expect)
|
|
for _, p := range pkgs {
|
|
assert.NotEmpty(t, p.Name)
|
|
assert.NotEmpty(t, p.Version)
|
|
assert.Equal(t, "aur", p.Repository)
|
|
assert.True(t, p.Installed)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestNew(t *testing.T) {
|
|
a := New()
|
|
assert.Equal(t, "aur", a.Name())
|
|
assert.Empty(t, a.BuildDir)
|
|
assert.Nil(t, a.MakepkgFlags)
|
|
}
|
|
|
|
func TestNewWithOptions(t *testing.T) {
|
|
a := NewWithOptions(
|
|
WithBuildDir("/tmp/aur-builds"),
|
|
WithMakepkgFlags("--skippgpcheck", "--nocheck"),
|
|
)
|
|
assert.Equal(t, "/tmp/aur-builds", a.BuildDir)
|
|
assert.Equal(t, []string{"--skippgpcheck", "--nocheck"}, a.MakepkgFlags)
|
|
}
|