Files
hyperguild/internal/tier/tier_test.go
Mathias Bergqvist d09f7fe7d8 feat: add tier detection package
Probes Anthropic and LiteLLM endpoints to detect the current operating
tier (Full / LANOnly / Airplane) so downstream code can gate model
selection and managed-agent availability without manual configuration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 20:28:29 +02:00

49 lines
1.4 KiB
Go

// internal/tier/tier_test.go
package tier_test
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/mathiasbq/supervisor/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)
}