Skip to content

refactor: simplify unsupported test channel types - #1963

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/refactor-channel-test
Oct 3, 2025
Merged

seefs001 merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/refactor-channel-test

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Oct 3, 2025 •

Copy link
Copy Markdown
Member

重构: 优化不支持测试渠道的判断逻辑

Summary by CodeRabbit

  • New Features

    • Added human-readable names for channel types, with a fallback to “Unknown.”
    • Provided a standardized accessor to retrieve channel type names.
  • Refactor

    • Consolidated unsupported channel checks into a single list with one containment check.
    • Unified and clarified error messages for unsupported channel tests using channel type names.
    • Preserved behavior for supported channels while simplifying control flow.

@coderabbitai

coderabbitai Bot commented Oct 3, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds exported channel type name mapping and accessor. Refactors channel test to centralize unsupported type checks using a list and a single conditional, generating a dynamic error message based on the channel type name. No other logic paths are altered.

Changes

Cohort / File(s) Summary
Constants: channel type names
constant/channel.go
Added exported ChannelTypeNames map and GetChannelTypeName(int) string to retrieve human-readable names; returns "Unknown" if unmapped.
Controller tests: unified unsupported checks
controller/channel-test.go
Imported lo for containment check, introduced unsupportedTestChannelTypes list, consolidated multiple per-type guards into one branch, and used channelTypeName in a single error message.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant TR as TestRunner
  participant CT as ChannelTest
  participant C as Constants

  TR->>CT: Run channel test
  CT->>C: GetChannelTypeName(channelType)
  C-->>CT: channelTypeName (or "Unknown")

  alt channelType in unsupportedTestChannelTypes
    note over CT: Unified unsupported branch
    CT-->>TR: error: "<name> channel test is not supported"
  else supported
    note over CT: Proceed with existing test flow
    CT-->>TR: continue with allowed-channel logic
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • creamlike1024
  • xyfacai

Poem

Thump-thump goes my coder heart, hop-hop through the code I go,
Names for channels neatly start, so humans quickly know.
One check to rule the rest, a tidy warren’s way,
If unsupported, say it best—then hippity on our way.
🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run `@coderabbitai generate docstrings` to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit's high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the core change—refactoring and simplifying the unsupported test channel type logic—using clear conventional-commit style without extraneous details.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b75bc0 and 937d931.

📒 Files selected for processing (2)
  • constant/channel.go (1 hunks)
  • controller/channel-test.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
controller/channel-test.go (1)
constant/channel.go (8)
  • ChannelTypeMidjourney (6-6)
  • ChannelTypeMidjourneyPlus (9-9)
  • ChannelTypeSunoAPI (36-36)
  • ChannelTypeKling (50-50)
  • ChannelTypeJimeng (51-51)
  • ChannelTypeDoubaoVideo (54-54)
  • ChannelTypeVidu (52-52)
  • GetChannelTypeName (171-176)
🔇 Additional comments (4)
constant/channel.go (2)

171-176: LGTM!

The GetChannelTypeName accessor correctly handles missing keys by returning "Unknown" as a safe fallback. The implementation is concise and idiomatic.


117-169: All ChannelType constants are mapped No missing or extra entries in ChannelTypeNames.

controller/channel-test.go (2)

44-58: Unsupported channel types list is complete
Confirmed no remaining individual channel type checks; list covers all unsupported types.


31-31: lo dependency declaration verified The github.com/samber/lo module is declared in go.mod at v1.39.0 and imported correctly across the codebase.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seefs001
seefs001 merged commit f24feed into QuantumNous:main Oct 3, 2025
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
…nel-test

refactor: simplify unsupported test channel types
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
…nel-test

refactor: simplify unsupported test channel types
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
…nel-test

refactor: simplify unsupported test channel types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants