35 lines
1.2 KiB
Go
35 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.yeij.top/AskaEth/Cyrene_v2/internal/capability/registry"
|
|
"git.yeij.top/AskaEth/Cyrene_v2/internal/capability/transcode"
|
|
)
|
|
|
|
// TestWireTranscodeRegistersTool 断言 wireTranscode 真的把转码装配起来了:引擎挂到
|
|
// app 上、`transcode` 工具进了能力注册表、且默认的 amr→wav 路可用。它是「组合根漏接
|
|
// 转码」这一整类回归的哨兵(design/25 §1.3.2)。
|
|
func TestWireTranscodeRegistersTool(t *testing.T) {
|
|
a := &app{log: testLog(), caps: registry.New()}
|
|
|
|
a.wireTranscode()
|
|
|
|
if a.transcoder == nil {
|
|
t.Fatal("wireTranscode 之后 a.transcoder 仍为 nil(引擎没被装配)")
|
|
}
|
|
cap, err := a.caps.Get(transcode.ToolName)
|
|
if err != nil {
|
|
t.Fatalf("transcode 工具没进能力注册表: %v", err)
|
|
}
|
|
if cap.Kind != registry.KindTool {
|
|
t.Fatalf("能力类型 = %q, want %q", cap.Kind, registry.KindTool)
|
|
}
|
|
if _, ok := cap.Value.(*transcode.Tool); !ok {
|
|
t.Fatalf("能力值类型 = %T, want *transcode.Tool", cap.Value)
|
|
}
|
|
if !a.transcoder.Supports(transcode.FormatAMR, transcode.FormatWAV) {
|
|
t.Fatal("装配后 amr->wav 这条路不可用(默认编解码器没进引擎)")
|
|
}
|
|
}
|