test(auth): skip keychain tests when dbus unavailable
Some checks failed
CI/CD Pipeline / Docker Build (push) Blocked by required conditions
Security Scan / Security Analysis (push) Waiting to run
Security Scan / Native Library Security (push) Waiting to run
Checkout test / test (push) Successful in 4s
CI/CD Pipeline / Test (push) Failing after 1s
CI/CD Pipeline / Dev Compose Smoke Test (push) Has been skipped
CI/CD Pipeline / Build (push) Has been skipped
CI/CD Pipeline / Test Scripts (push) Has been skipped
CI/CD Pipeline / Test Native Libraries (push) Has been skipped
Documentation / build-and-publish (push) Has been cancelled

This commit is contained in:
Jeremie Fraeys 2026-02-21 21:20:03 -05:00
parent 1b0781dc68
commit bf4a8bcf78
No known key found for this signature in database

View file

@ -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()