Files
snack/dpkg/dpkg_integration_test.go
Tai Groot b443269594 feat: add integration tests and GitHub Actions CI
Add integration test files for all providers (apt, dpkg, pacman, apk,
dnf, rpm, flatpak, snap, pkg, detect) behind the 'integration' build
tag. Tests exercise real package operations: update, search, info,
install, verify, list, remove, and capability interfaces.

Add GitHub Actions workflow running unit tests on ubuntu-latest and
integration tests on Debian, Ubuntu, Fedora, Alpine, Arch Linux, and
Ubuntu+Flatpak containers/runners.
2026-02-26 01:42:19 +00:00

66 lines
1.4 KiB
Go

//go:build integration
package dpkg_test
import (
"context"
"testing"
"github.com/gogrlx/snack"
"github.com/gogrlx/snack/dpkg"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestIntegration_Dpkg(t *testing.T) {
mgr := dpkg.New()
if !mgr.Available() {
t.Skip("dpkg not available")
}
ctx := context.Background()
t.Run("List", func(t *testing.T) {
pkgs, err := mgr.List(ctx)
require.NoError(t, err)
require.NotEmpty(t, pkgs)
})
t.Run("IsInstalled", func(t *testing.T) {
// bash should always be installed
installed, err := mgr.IsInstalled(ctx, "bash")
require.NoError(t, err)
assert.True(t, installed)
})
t.Run("Version", func(t *testing.T) {
ver, err := mgr.Version(ctx, "bash")
require.NoError(t, err)
assert.NotEmpty(t, ver)
})
t.Run("Info", func(t *testing.T) {
pkg, err := mgr.Info(ctx, "bash")
require.NoError(t, err)
require.NotNil(t, pkg)
assert.Equal(t, "bash", pkg.Name)
})
t.Run("Search", func(t *testing.T) {
pkgs, err := mgr.Search(ctx, "bash")
require.NoError(t, err)
require.NotEmpty(t, pkgs)
})
t.Run("FileOwner", func(t *testing.T) {
if fo, ok := mgr.(snack.FileOwner); ok {
owner, err := fo.Owner(ctx, "/bin/bash")
require.NoError(t, err)
assert.NotEmpty(t, owner)
files, err := fo.FileList(ctx, "bash")
require.NoError(t, err)
assert.NotEmpty(t, files)
}
})
}