mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-01 20:58:42 -07:00
fix(ci): update integration tests for NameNormalizer, fix lint and Windows CI
- Update apk/pacman/snap/flatpak integration tests to assert NameNormalize=true (all managers now implement NameNormalizer) - Update flatpak integration test to assert VersionQuery=true - Remove unused aur functions: rpcInfoMulti, getAURBuildDir - Wire AUR.Clean to call clean() for consistency - Fix Windows CI: add shell:bash to avoid PowerShell arg splitting on -coverprofile=coverage-windows.out
This commit is contained in:
1
.github/workflows/integration.yml
vendored
1
.github/workflows/integration.yml
vendored
@@ -211,6 +211,7 @@ jobs:
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- name: Unit tests
|
||||
shell: bash
|
||||
run: go test -race -coverprofile=coverage-windows.out ./winget/ ./detect/
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestIntegration_Apk(t *testing.T) {
|
||||
assert.False(t, caps.RepoManagement, "apk should not support RepoManagement")
|
||||
assert.False(t, caps.KeyManagement, "apk should not support KeyManagement")
|
||||
assert.False(t, caps.Groups, "apk should not support Groups")
|
||||
assert.False(t, caps.NameNormalize, "apk should not support NameNormalize")
|
||||
assert.True(t, caps.NameNormalize, "apk should support NameNormalize")
|
||||
|
||||
t.Run("Update", func(t *testing.T) {
|
||||
require.NoError(t, mgr.Update(ctx))
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gogrlx/snack"
|
||||
@@ -380,14 +379,4 @@ func upgradePackages(ctx context.Context, pkgs []snack.Target, opts ...snack.Opt
|
||||
return install(ctx, pkgs, allOpts...)
|
||||
}
|
||||
|
||||
// getAURBuildDir returns the directory to use for AUR builds.
|
||||
func getAURBuildDir() string {
|
||||
if dir := os.Getenv("AURDEST"); dir != "" {
|
||||
return dir
|
||||
}
|
||||
if cache := os.Getenv("XDG_CACHE_HOME"); cache != "" {
|
||||
return filepath.Join(cache, "aur")
|
||||
}
|
||||
home, _ := os.UserHomeDir()
|
||||
return filepath.Join(home, ".cache", "aur")
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ func (a *AUR) Autoremove(ctx context.Context, opts ...snack.Option) error {
|
||||
}
|
||||
|
||||
// Clean is a no-op for AUR (builds use temp directories).
|
||||
func (a *AUR) Clean(_ context.Context) error {
|
||||
return nil
|
||||
func (a *AUR) Clean(ctx context.Context) error {
|
||||
return clean(ctx)
|
||||
}
|
||||
|
||||
// UpgradePackages rebuilds and reinstalls specific AUR packages.
|
||||
|
||||
21
aur/rpc.go
21
aur/rpc.go
@@ -7,7 +7,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gogrlx/snack"
|
||||
)
|
||||
@@ -117,23 +116,3 @@ func rpcInfo(ctx context.Context, pkg string) (*snack.Package, error) {
|
||||
return &p, nil
|
||||
}
|
||||
|
||||
// rpcInfoMulti returns info about multiple AUR packages in a single request.
|
||||
func rpcInfoMulti(ctx context.Context, pkgs []string) (map[string]rpcResult, error) {
|
||||
if len(pkgs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
params := make([]string, len(pkgs))
|
||||
for i, p := range pkgs {
|
||||
params[i] = "arg[]=" + url.QueryEscape(p)
|
||||
}
|
||||
endpoint := rpcBaseURL + "/info?" + strings.Join(params, "&")
|
||||
resp, err := rpcGet(ctx, endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make(map[string]rpcResult, len(resp.Results))
|
||||
for _, r := range resp.Results {
|
||||
result[r.Name] = r
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ func TestIntegration_Flatpak(t *testing.T) {
|
||||
caps := snack.GetCapabilities(mgr)
|
||||
assert.True(t, caps.Clean, "flatpak should support Clean")
|
||||
assert.True(t, caps.RepoManagement, "flatpak should support RepoManagement")
|
||||
assert.False(t, caps.VersionQuery)
|
||||
assert.True(t, caps.VersionQuery, "flatpak should support VersionQuery")
|
||||
assert.False(t, caps.Hold)
|
||||
assert.False(t, caps.FileOwnership)
|
||||
assert.False(t, caps.KeyManagement)
|
||||
assert.False(t, caps.Groups)
|
||||
assert.False(t, caps.NameNormalize)
|
||||
assert.True(t, caps.NameNormalize, "flatpak should support NameNormalize")
|
||||
|
||||
t.Run("Update", func(t *testing.T) {
|
||||
require.NoError(t, mgr.Update(ctx))
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestIntegration_Pacman(t *testing.T) {
|
||||
assert.False(t, caps.Hold, "pacman should not support Hold")
|
||||
assert.False(t, caps.RepoManagement, "pacman should not support RepoManagement")
|
||||
assert.False(t, caps.KeyManagement, "pacman should not support KeyManagement")
|
||||
assert.False(t, caps.NameNormalize, "pacman should not support NameNormalize")
|
||||
assert.True(t, caps.NameNormalize, "pacman should support NameNormalize")
|
||||
|
||||
t.Run("Update", func(t *testing.T) {
|
||||
require.NoError(t, mgr.Update(ctx))
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestIntegration_Snap(t *testing.T) {
|
||||
assert.False(t, caps.RepoManagement)
|
||||
assert.False(t, caps.KeyManagement)
|
||||
assert.False(t, caps.Groups)
|
||||
assert.False(t, caps.NameNormalize)
|
||||
assert.True(t, caps.NameNormalize, "snap should support NameNormalize")
|
||||
|
||||
t.Run("Update", func(t *testing.T) {
|
||||
require.NoError(t, mgr.Update(ctx))
|
||||
|
||||
Reference in New Issue
Block a user