openai_gateway_usage_integrity_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //go:build unit
  2. package service
  3. import (
  4. "testing"
  5. "github.com/stretchr/testify/require"
  6. )
  7. func TestRequiresBillableGrokChatUsage(t *testing.T) {
  8. t.Parallel()
  9. tests := []struct {
  10. name string
  11. account *Account
  12. models []string
  13. want bool
  14. }{
  15. {
  16. name: "grok platform",
  17. account: &Account{Platform: PlatformGrok},
  18. models: []string{"alias"},
  19. want: true,
  20. },
  21. {
  22. name: "OpenAI-compatible requested Grok model",
  23. account: &Account{Platform: PlatformOpenAI},
  24. models: []string{"grok-4.5"},
  25. want: true,
  26. },
  27. {
  28. name: "OpenAI-compatible mapped Grok model",
  29. account: &Account{Platform: PlatformOpenAI},
  30. models: []string{"alias", "grok-4.5"},
  31. want: true,
  32. },
  33. {
  34. name: "xAI-qualified Grok model",
  35. account: &Account{Platform: PlatformOpenAI},
  36. models: []string{"xai/grok-4.5"},
  37. want: true,
  38. },
  39. {
  40. name: "ordinary OpenAI model",
  41. account: &Account{Platform: PlatformOpenAI},
  42. models: []string{"gpt-5.4"},
  43. want: false,
  44. },
  45. }
  46. for _, tt := range tests {
  47. t.Run(tt.name, func(t *testing.T) {
  48. t.Parallel()
  49. require.Equal(t, tt.want, requiresBillableGrokChatUsage(tt.account, tt.models...))
  50. })
  51. }
  52. }