TSI-3419: feat(encoder): 补单测断言 CanTranslate(AV1, H264)==false 拒绝分支 - #77
Merged
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a unit test that verifies TranslatorAdapter rejects AV1-to-H.264 mappings while continuing to advertise supported AV1-to-AV1 translation rules. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pkg/encoder/rewrite/engine_test.go" line_range="769-780" />
<code_context>
+func TestTranslatorAdapter_CanTranslate_CrossFormatRejected(t *testing.T) {
+ adapter := NewTranslatorAdapter()
+
+ if adapter.CanTranslate(encoder.EncoderLibSVTAV1, encoder.EncoderLibX264) {
+ t.Error("CanTranslate(AV1, H.264) should be false: cross-format translation is rejected")
+ }
+
</code_context>
<issue_to_address>
**issue (testing):** The test claims to verify that all AV1-to-H.264 translations are rejected, but it checks only the single target `EncoderLibX264`. If a direct AV1-to-H.264 rule is added for `EncoderH264NVENC`, `EncoderH264QSV`, or another H.264 family, this test still passes while the stated cross-format invariant is broken.
**Triggers:** When a direct translation rule is added for an AV1 source and any H.264 target other than `EncoderLibX264`.
**Suggested fix:** Iterate over every registered H.264 encoder family and assert that `CanTranslate(AV1Source, h264Target)` is false, or explicitly narrow the test name and comment to the libx264 target.
```suggestion
// TestTranslatorAdapter_CanTranslate_AV1ToLibX264Rejected verifies that
// cross-format translation to libx264 is refused: rewriting AV1 parameters
// to an H.264 encoder would silently change the requested output codec. This
// test specifically covers the libx264 target.
func TestTranslatorAdapter_CanTranslate_AV1ToLibX264Rejected(t *testing.T) {
adapter := NewTranslatorAdapter()
if adapter.CanTranslate(encoder.EncoderLibSVTAV1, encoder.EncoderLibX264) {
t.Error("CanTranslate(AV1, libx264) should be false: cross-format translation is rejected")
}
```
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: pkg/encoder/rewrite/engine_test.go:780
Contributor
Author
|
REQUEST CHANGES(Radian 代码审查) 审查摘要
阻塞问题
注:PR 由本 GitHub App 身份创建,GitHub 禁止其对自身 PR 提交正式 review(REQUEST_CHANGES/APPROVE/COMMENTED 均被 422 拒绝),故改为 diff 行内评论 + 本条总结;裁决以 issue 评论为准。 |
multica-tsic404
Bot
force-pushed
the
multica/TSI-3419
branch
from
September 21, 2026 09:24
fb37a26 to
9979886
Compare
Contributor
Author
|
APPROVED(Radian 复审 · 提交 审查摘要
注:本 PR 由 GitHub App 身份创建,GitHub 禁止其对自身 PR 提交正式 APPROVE review(422),故以本条总结发布;裁决以 issue 评论为准。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes TSI-3419
Summary by Sourcery
Tests: