channel_bedrock_cc_test.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package service
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/require"
  5. )
  6. func TestChannel_IsBedrockCCCompatEnabled_Enabled(t *testing.T) {
  7. c := &Channel{
  8. FeaturesConfig: map[string]any{
  9. featureKeyBedrockCCCompat: true,
  10. },
  11. }
  12. require.True(t, c.IsBedrockCCCompatEnabled("bedrock"))
  13. }
  14. func TestChannel_IsBedrockCCCompatEnabled_AppliesToAllPlatforms(t *testing.T) {
  15. c := &Channel{
  16. FeaturesConfig: map[string]any{
  17. featureKeyBedrockCCCompat: true,
  18. },
  19. }
  20. require.True(t, c.IsBedrockCCCompatEnabled("anthropic"))
  21. require.True(t, c.IsBedrockCCCompatEnabled("openai"))
  22. require.True(t, c.IsBedrockCCCompatEnabled(""))
  23. }
  24. func TestChannel_IsBedrockCCCompatEnabled_Disabled(t *testing.T) {
  25. c := &Channel{
  26. FeaturesConfig: map[string]any{
  27. featureKeyBedrockCCCompat: false,
  28. },
  29. }
  30. require.False(t, c.IsBedrockCCCompatEnabled("bedrock"))
  31. }
  32. func TestChannel_IsBedrockCCCompatEnabled_NilFeaturesConfig(t *testing.T) {
  33. c := &Channel{FeaturesConfig: nil}
  34. require.False(t, c.IsBedrockCCCompatEnabled("bedrock"))
  35. }
  36. func TestChannel_IsBedrockCCCompatEnabled_NilChannel(t *testing.T) {
  37. var c *Channel
  38. require.False(t, c.IsBedrockCCCompatEnabled("bedrock"))
  39. }
  40. func TestChannel_IsBedrockCCCompatEnabled_WrongType(t *testing.T) {
  41. c := &Channel{
  42. FeaturesConfig: map[string]any{
  43. featureKeyBedrockCCCompat: "yes",
  44. },
  45. }
  46. require.False(t, c.IsBedrockCCCompatEnabled("bedrock"))
  47. }
  48. func TestChannel_IsBedrockCCCompatEnabled_OldMapFormat(t *testing.T) {
  49. c := &Channel{
  50. FeaturesConfig: map[string]any{
  51. featureKeyBedrockCCCompat: map[string]any{"bedrock": true},
  52. },
  53. }
  54. require.False(t, c.IsBedrockCCCompatEnabled("bedrock"))
  55. }
  56. func TestChannel_IsBedrockCCCompatEnabled_MissingKey(t *testing.T) {
  57. c := &Channel{
  58. FeaturesConfig: map[string]any{
  59. "other_feature": true,
  60. },
  61. }
  62. require.False(t, c.IsBedrockCCCompatEnabled("bedrock"))
  63. }