package ai

import (
	"testing"

	"github.com/ultisuite/ulti-backend/internal/ai/cost"
)

func TestParseUsageViaCost(t *testing.T) {
	payload := []byte(`{"usage":{"total_tokens":42,"completion_tokens":10}}`)
	u := cost.ParseUsage(payload)
	if u.TotalTokens != 42 {
		t.Fatalf("ParseUsage() = %d, want 42", u.TotalTokens)
	}
}

func TestParseUsageFallback(t *testing.T) {
	u := cost.ParseUsage([]byte(`{"choices":[]}`))
	if u.TotalTokens != 1 {
		t.Fatalf("expected fallback token count 1, got %d", u.TotalTokens)
	}
}
