Files
hyperguild/internal/tier/tier_test.go
T
mathiasandClaude Sonnet 5 b600cc986c
CI / Lint / Test / Vet (push) Failing after 5s
CI / Mirror to GitHub (push) Has been skipped
chore(module): rename module github.com/mathiasbq/supervisor -> git.d-ma.be/mathias/hyperguild (#42)
Aligns module path with canonical Gitea source (infra ADR-0004) and
repo name. Binary only, no downstream consumers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Roq1ajWKR5f1hG5Df9wC6A
2026-07-26 23:37:11 +02:00

49 lines
1.4 KiB
Go

// internal/tier/tier_test.go
package tier_test
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"git.d-ma.be/mathias/hyperguild/internal/tier"
"github.com/stretchr/testify/assert"
)
func TestDetect_Tier1_WhenBothReachable(t *testing.T) {
anthropic := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}))
defer anthropic.Close()
litellm := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}))
defer litellm.Close()
info := tier.Detect(context.Background(), anthropic.URL, litellm.URL)
assert.Equal(t, tier.Full, info.Tier)
assert.Equal(t, "full-online", info.Label)
assert.True(t, info.ManagedAgents)
}
func TestDetect_Tier2_WhenOnlyLiteLLMReachable(t *testing.T) {
litellm := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}))
defer litellm.Close()
info := tier.Detect(context.Background(), "http://127.0.0.1:1", litellm.URL)
assert.Equal(t, tier.LANOnly, info.Tier)
assert.Equal(t, "lan-only", info.Label)
assert.False(t, info.ManagedAgents)
}
func TestDetect_Tier3_WhenNeitherReachable(t *testing.T) {
info := tier.Detect(context.Background(), "http://127.0.0.1:1", "http://127.0.0.1:2")
assert.Equal(t, tier.Airplane, info.Tier)
assert.Equal(t, "airplane", info.Label)
assert.False(t, info.ManagedAgents)
}