From bf4a8bcf788327fc3b80bcca8d1c07ca52f597d4 Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Sat, 21 Feb 2026 21:20:03 -0500 Subject: [PATCH] test(auth): skip keychain tests when dbus unavailable --- tests/unit/auth/keychain_test.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) 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()