tests: beginning of tests using Docker

This commit is contained in:
2025-07-04 09:02:27 -05:00
parent 7be2679b91
commit 305b504ca1
52 changed files with 1423 additions and 521 deletions

View File

@ -4,26 +4,26 @@ import (
"fmt"
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/apt"
packagemanagercommon "git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/common"
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/dnf"
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/pkgcommon"
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/yum"
)
// PackageManager is an interface used to define common package commands. This shall be implemented by every package.
type PackageManager interface {
Install(pkg, version string, args []string) (string, []string)
Remove(pkg string, args []string) (string, []string)
Upgrade(pkg, version string) (string, []string) // Upgrade a specific package
Install(pkgs []packagemanagercommon.Package, args []string) (string, []string)
Remove(pkgs []packagemanagercommon.Package, args []string) (string, []string)
Upgrade(pkgs []packagemanagercommon.Package) (string, []string) // Upgrade a specific package
UpgradeAll() (string, []string)
CheckVersion(pkg, version string) (string, []string)
Parse(output string) (*pkgcommon.PackageVersion, error)
CheckVersion(pkgs []packagemanagercommon.Package) (string, []string)
ParseRemotePackageManagerVersionOutput(output string) ([]packagemanagercommon.Package, []error)
// Configure applies functional options to customize the package manager.
Configure(options ...pkgcommon.PackageManagerOption)
Configure(options ...packagemanagercommon.PackageManagerOption)
}
// PackageManagerFactory returns the appropriate PackageManager based on the package tool.
// Takes variable number of options.
func PackageManagerFactory(managerType string, options ...pkgcommon.PackageManagerOption) (PackageManager, error) {
func PackageManagerFactory(managerType string, options ...packagemanagercommon.PackageManagerOption) (PackageManager, error) {
var manager PackageManager
switch managerType {
@ -43,7 +43,7 @@ func PackageManagerFactory(managerType string, options ...pkgcommon.PackageManag
}
// WithAuth enables authentication and sets the authentication command.
func WithAuth(authCommand string) pkgcommon.PackageManagerOption {
func WithAuth(authCommand string) packagemanagercommon.PackageManagerOption {
return func(manager interface{}) {
if configurable, ok := manager.(interface {
SetUseAuth(bool)
@ -56,7 +56,7 @@ func WithAuth(authCommand string) pkgcommon.PackageManagerOption {
}
// WithoutAuth disables authentication.
func WithoutAuth() pkgcommon.PackageManagerOption {
func WithoutAuth() packagemanagercommon.PackageManagerOption {
return func(manager interface{}) {
if configurable, ok := manager.(interface {
SetUseAuth(bool)
@ -68,8 +68,8 @@ func WithoutAuth() pkgcommon.PackageManagerOption {
// ConfigurablePackageManager defines methods for setting configuration options.
type ConfigurablePackageManager interface {
pkgcommon.PackageParser
packagemanagercommon.PackageParser
SetUseAuth(useAuth bool)
SetAuthCommand(authCommand string)
SetPackageParser(parser pkgcommon.PackageParser)
SetPackageParser(parser packagemanagercommon.PackageParser)
}