This commit is contained in:
Yvan
2026-09-23 09:03:17 +08:00
parent 80c8c6308a
commit 672c7f8f6c
5 changed files with 109 additions and 9 deletions
+27
View File
@@ -3,6 +3,7 @@ package live
import (
"context"
"encoding/json"
"strings"
"sync"
"testing"
@@ -480,3 +481,29 @@ func TestClosedSupersededPeerConnectionDoesNotRemovePeer(t *testing.T) {
}
var _ platformws.Hub = (*liveHubStub)(nil)
func TestNewPionAPIRejectsConflictingUDPConfiguration(t *testing.T) {
t.Setenv("KRA_LIVE_UDP_PORT", "40000")
t.Setenv("KRA_LIVE_UDP_MIN_PORT", "40000")
t.Setenv("KRA_LIVE_UDP_MAX_PORT", "40010")
_, closer, err := newPionAPI()
if closer != nil {
_ = closer.Close()
}
if err == nil || !strings.Contains(err.Error(), "cannot be combined") {
t.Fatalf("newPionAPI error = %v, want conflicting UDP configuration", err)
}
}
func TestNewPionAPIRejectsInvalidPublicIP(t *testing.T) {
t.Setenv("KRA_LIVE_PUBLIC_IP", "live.example.com")
_, closer, err := newPionAPI()
if closer != nil {
_ = closer.Close()
}
if err == nil || !strings.Contains(err.Error(), "invalid KRA_LIVE_PUBLIC_IP") {
t.Fatalf("newPionAPI error = %v, want invalid public IP", err)
}
}