mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-04 04:26:38 +08:00
fix: enforce transcoding resource controls
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ShukeBta/MediaStationGo/internal/config"
|
||||
)
|
||||
|
||||
func TestApplyRuntimeSettingTranscodeSwitches(t *testing.T) {
|
||||
cfg := &config.Config{}
|
||||
cfg.Transcoder.Enabled = true
|
||||
cfg.Transcoder.HardwareAccel = false
|
||||
|
||||
ApplyRuntimeSetting(cfg, "transcode.enabled", "false")
|
||||
if cfg.Transcoder.Enabled {
|
||||
t.Fatal("transcode.enabled=false should disable transcoding")
|
||||
}
|
||||
|
||||
ApplyRuntimeSetting(cfg, "transcode.hw_enabled", "true")
|
||||
if !cfg.Transcoder.HardwareAccel {
|
||||
t.Fatal("transcode.hw_enabled=true should enable hardware accel")
|
||||
}
|
||||
|
||||
ApplyRuntimeSetting(cfg, "transcode.hw_accel", "nvenc")
|
||||
if cfg.Transcoder.Encoder != "nvenc" {
|
||||
t.Fatalf("encoder = %q, want nvenc", cfg.Transcoder.Encoder)
|
||||
}
|
||||
|
||||
ApplyRuntimeSetting(cfg, "transcode.max_jobs", "1")
|
||||
if cfg.Transcoder.MaxConcurrent != 1 {
|
||||
t.Fatalf("max concurrent = %d, want 1", cfg.Transcoder.MaxConcurrent)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user