mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-05-31 09:29:45 +00:00
test(mobile): reuse room fixture
This commit is contained in:
@@ -53,6 +53,8 @@ func resetMobileGlobals(t *testing.T) {
|
||||
|
||||
var clientRunWithReady = runClientWithReady //nolint:gochecknoglobals // package-level state intentional
|
||||
|
||||
const testRoom = "room"
|
||||
|
||||
var (
|
||||
errMobileCheckFailed = errors.New("check failed")
|
||||
errMobileRunFailed = errors.New("run failed")
|
||||
@@ -128,7 +130,7 @@ func TestNormalizeBuildRoomAndClamp(t *testing.T) {
|
||||
if got := buildRoomURL("telemost", "abc"); got != "abc" {
|
||||
t.Fatalf("telemost room URL = %q", got)
|
||||
}
|
||||
if got := buildRoomURL(carrierWBStream, "room"); got != "room" {
|
||||
if got := buildRoomURL(carrierWBStream, testRoom); got != testRoom {
|
||||
t.Fatalf("wbstream room URL = %q", got)
|
||||
}
|
||||
|
||||
@@ -140,23 +142,23 @@ func TestNormalizeBuildRoomAndClamp(t *testing.T) {
|
||||
func TestStartValidation(t *testing.T) {
|
||||
resetMobileGlobals(t)
|
||||
|
||||
if err := startWithConfig("", dataTransport, "room", "client", "key", 1080, "", "", mobileConfig{}); !errors.Is(err, errCarrierRequired) { //nolint:lll // long test description
|
||||
if err := startWithConfig("", dataTransport, testRoom, "client", "key", 1080, "", "", mobileConfig{}); !errors.Is(err, errCarrierRequired) { //nolint:lll // long test description
|
||||
t.Fatalf("startWithConfig(missing carrier) = %v", err)
|
||||
}
|
||||
if err := startWithConfig("telemost", dataTransport, "", "client", "key", 1080, "", "", mobileConfig{}); !errors.Is(err, errRoomIDRequired) { //nolint:lll // long test description
|
||||
t.Fatalf("startWithConfig(missing room) = %v", err)
|
||||
}
|
||||
if err := startWithConfig("jitsi", dataTransport, "room", "", "key", 1080, "", "", mobileConfig{}); !errors.Is(err, errClientIDRequired) { //nolint:lll // long test description
|
||||
if err := startWithConfig("jitsi", dataTransport, testRoom, "", "key", 1080, "", "", mobileConfig{}); !errors.Is(err, errClientIDRequired) { //nolint:lll // long test description
|
||||
t.Fatalf("startWithConfig(missing client) = %v", err)
|
||||
}
|
||||
if err := startWithConfig("jitsi", dataTransport, "room", "client", "", 1080, "", "", mobileConfig{}); !errors.Is(err, errKeyHexRequired) { //nolint:lll // long test description
|
||||
if err := startWithConfig("jitsi", dataTransport, testRoom, "client", "", 1080, "", "", mobileConfig{}); !errors.Is(err, errKeyHexRequired) { //nolint:lll // long test description
|
||||
t.Fatalf("startWithConfig(missing key) = %v", err)
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
cancel = func() {}
|
||||
mu.Unlock()
|
||||
if err := startWithConfig("jitsi", dataTransport, "room", "client", "key", 1080, "", "", mobileConfig{}); !errors.Is(err, errAlreadyRunning) { //nolint:lll // long test description
|
||||
if err := startWithConfig("jitsi", dataTransport, testRoom, "client", "key", 1080, "", "", mobileConfig{}); !errors.Is(err, errAlreadyRunning) { //nolint:lll // long test description
|
||||
t.Fatalf("startWithConfig(running) = %v", err)
|
||||
}
|
||||
resetMobileGlobals(t)
|
||||
@@ -174,7 +176,7 @@ func TestStartWithInjectedRunnerLifecycle(t *testing.T) {
|
||||
runClientWithReady = func(ctx context.Context, cfg client.Config, onReady func()) error {
|
||||
opts, _ := cfg.TransportOptions.(vp8channel.Options)
|
||||
if cfg.Transport != dataTransport || cfg.Carrier != "jitsi" ||
|
||||
cfg.RoomURL != "room" || cfg.DeviceID != "client" || cfg.LocalAddr != "0.0.0.0:1080" ||
|
||||
cfg.RoomURL != testRoom || cfg.DeviceID != "client" || cfg.LocalAddr != "0.0.0.0:1080" ||
|
||||
cfg.DNSServer != defaultDNSServer || opts.FPS != 60 || opts.BatchSize != 8 ||
|
||||
cfg.Liveness.Interval != 2500*time.Millisecond ||
|
||||
cfg.Liveness.Timeout != 750*time.Millisecond ||
|
||||
@@ -191,7 +193,7 @@ func TestStartWithInjectedRunnerLifecycle(t *testing.T) {
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
if err := StartWithTransport("jitsi", "dc", "room", "client", "key", 1080, "", ""); err != nil {
|
||||
if err := StartWithTransport("jitsi", "dc", testRoom, "client", "key", 1080, "", ""); err != nil {
|
||||
t.Fatalf("StartWithTransport() error = %v", err)
|
||||
}
|
||||
if !IsRunning() {
|
||||
@@ -214,7 +216,7 @@ func TestStartUsesDefaultsAndCheckWithInjectedRunner(t *testing.T) {
|
||||
})
|
||||
|
||||
runClientWithReady = func(ctx context.Context, cfg client.Config, onReady func()) error {
|
||||
if cfg.Transport != defaultTransport || cfg.RoomURL != "room" ||
|
||||
if cfg.Transport != defaultTransport || cfg.RoomURL != testRoom ||
|
||||
cfg.LocalAddr != "127.0.0.1:1081" || cfg.SOCKSUser != "u" || cfg.SOCKSPass != "p" ||
|
||||
cfg.Liveness.Interval != control.DefaultInterval ||
|
||||
cfg.Liveness.Timeout != control.DefaultTimeout ||
|
||||
@@ -227,7 +229,7 @@ func TestStartUsesDefaultsAndCheckWithInjectedRunner(t *testing.T) {
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
if err := Start("telemost", "room", "client", "key", 1081, "u", "p"); err != nil {
|
||||
if err := Start("telemost", testRoom, "client", "key", 1081, "u", "p"); err != nil {
|
||||
t.Fatalf("Start() error = %v", err)
|
||||
}
|
||||
if err := WaitReady(100); err != nil {
|
||||
@@ -249,7 +251,7 @@ func TestStartUsesDefaultsAndCheckWithInjectedRunner(t *testing.T) {
|
||||
<-ctx.Done()
|
||||
return nil
|
||||
}
|
||||
elapsed, err := Check("jitsi", "dc", "room", "client", "key", 1082, 100, -1, 999)
|
||||
elapsed, err := Check("jitsi", "dc", testRoom, "client", "key", 1082, 100, -1, 999)
|
||||
if err != nil {
|
||||
t.Fatalf("Check() error = %v", err)
|
||||
}
|
||||
@@ -273,7 +275,7 @@ func TestPingPassesLiveness(t *testing.T) {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, _ = Ping("jitsi", "dc", "room", "client", "key", 1085, 100, "http://127.0.0.1/", 30, 1)
|
||||
_, _ = Ping("jitsi", "dc", testRoom, "client", "key", 1085, 100, "http://127.0.0.1/", 30, 1)
|
||||
select {
|
||||
case got := <-seen:
|
||||
if got.Interval != 4000*time.Millisecond || got.Timeout != 1500*time.Millisecond || got.Failures != 6 {
|
||||
@@ -294,7 +296,7 @@ func TestCheckTimeoutAndRunError(t *testing.T) {
|
||||
<-ctx.Done()
|
||||
return nil
|
||||
}
|
||||
if _, err := Check("telemost", defaultTransport, "room", "client", "key", 1083, 1, 30, 1); !errors.Is(err, errStartTimedOut) { //nolint:lll // long test description
|
||||
if _, err := Check("telemost", defaultTransport, testRoom, "client", "key", 1083, 1, 30, 1); !errors.Is(err, errStartTimedOut) { //nolint:lll // long test description
|
||||
t.Fatalf("Check(timeout) error = %v, want %v", err, errStartTimedOut)
|
||||
}
|
||||
|
||||
@@ -302,7 +304,7 @@ func TestCheckTimeoutAndRunError(t *testing.T) {
|
||||
runClientWithReady = func(context.Context, client.Config, func()) error {
|
||||
return want
|
||||
}
|
||||
if _, err := Check("telemost", defaultTransport, "room", "client", "key", 1084, 100, 30, 1); !errors.Is(err, want) {
|
||||
if _, err := Check("telemost", defaultTransport, testRoom, "client", "key", 1084, 100, 30, 1); !errors.Is(err, want) {
|
||||
t.Fatalf("Check(run error) = %v, want %v", err, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user