diff --git a/tests/unit/auth/keychain_test.go b/tests/unit/auth/keychain_test.go index 7f9c168..cf08677 100644 --- a/tests/unit/auth/keychain_test.go +++ b/tests/unit/auth/keychain_test.go @@ -1,21 +1,30 @@ package auth import ( + "os/exec" "strings" "testing" "github.com/jfraeys/fetch_ml/internal/auth" ) +// isKeyringAvailable checks if dbus is available for keyring operations +func isKeyringAvailable() bool { + // Check if dbus-launch is available (Linux keyring requirement) + if _, err := exec.LookPath("dbus-launch"); err != nil { + return false + } + return true +} + func TestNewKeychainManager(t *testing.T) { - t.Parallel() // Enable parallel execution + t.Parallel() km := auth.NewKeychainManager() if km == nil { t.Fatal("NewKeychainManager returned nil") } - // Test that ListAvailableMethods works methods := km.ListAvailableMethods() if len(methods) == 0 { t.Error("Expected at least one available method") @@ -36,7 +45,11 @@ func TestKeychainIsAvailable(t *testing.T) { } func TestKeychainBasicOperations(t *testing.T) { - t.Parallel() // Enable parallel execution + t.Parallel() + + if !isKeyringAvailable() { + t.Skip("Skipping: dbus-launch not available for keyring operations") + } km := auth.NewKeychainManager() @@ -118,7 +131,11 @@ func TestKeychainErrorHandling(t *testing.T) { } func TestKeychainMultipleKeys(t *testing.T) { - t.Parallel() // Enable parallel execution + t.Parallel() + + if !isKeyringAvailable() { + t.Skip("Skipping: dbus-launch not available for keyring operations") + } km := auth.NewKeychainManager()