Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions runtime/preflight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package runtime
import (
"context"
"encoding/json"
"errors"
"os"
"path/filepath"
"strings"
Expand All @@ -12,6 +13,28 @@ import (
"github.com/GrayCodeAI/eyrie/credentials"
)

// failingStore is a mock credential store that always returns errors.
type failingStore struct{}

func (f *failingStore) Set(ctx context.Context, account, secret string) error {
_ = ctx
_ = account
_ = secret
return errors.New("mock failing store: Set not implemented")
}

func (f *failingStore) Get(ctx context.Context, account string) (string, error) {
_ = ctx
_ = account
return "", errors.New("mock failing store: Get not implemented")
}

func (f *failingStore) Delete(ctx context.Context, account string) error {
_ = ctx
_ = account
return errors.New("mock failing store: Delete not implemented")
}

// --- PreflightStatus constants ---

func TestPreflightStatusConstants(t *testing.T) {
Expand Down Expand Up @@ -176,6 +199,9 @@ func TestPreflight_KeychainCheck(t *testing.T) {
func TestPreflight_NotReady_WhenCredentialsFail(t *testing.T) {
setupPreflightEnv(t, "{}\n")

// Use failing store to ensure credentials check fails
credentials.SetDefaultStore(&failingStore{})

r := Preflight(context.Background())
// If credentials check fails, Ready should be false.
for _, c := range r.Checks {
Expand All @@ -186,8 +212,7 @@ func TestPreflight_NotReady_WhenCredentialsFail(t *testing.T) {
return
}
}
// If creds check doesn't fail (edge case), skip
t.Skip("credentials check did not fail in this environment") // TODO: https://github.com/GrayCodeAI/eyrie/issues/28
t.Fatal("expected credentials check to fail with failing store")
}

func TestPreflight_WithValidModel(t *testing.T) {
Expand Down Expand Up @@ -394,6 +419,9 @@ func TestPreflight_CheckNames(t *testing.T) {
func TestPreflight_MultipleFailures(t *testing.T) {
setupPreflightEnv(t, "{}\n")

// Use failing store to ensure credential failures
credentials.SetDefaultStore(&failingStore{})

r := Preflight(context.Background())
failCount := 0
for _, c := range r.Checks {
Expand All @@ -402,7 +430,7 @@ func TestPreflight_MultipleFailures(t *testing.T) {
}
}
if failCount == 0 {
t.Skip("no failures detected in this environment") // TODO: https://github.com/GrayCodeAI/eyrie/issues/29
t.Fatal("expected at least one failure with failing store")
}
if r.Ready {
t.Fatal("expected not ready with failures")
Expand Down
Loading