diff --git a/mobile/mobile_test.go b/mobile/mobile_test.go index f16a893..4a2db48 100644 --- a/mobile/mobile_test.go +++ b/mobile/mobile_test.go @@ -53,6 +53,8 @@ func resetMobileGlobals(t *testing.T) { var clientRunWithReady = runClientWithReady //nolint:gochecknoglobals // package-level state intentional +const testRoomID = "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, testRoomID); got != testRoomID { 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, testRoomID, "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, testRoomID, "", "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, testRoomID, "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, testRoomID, "client", "key", 1080, "", "", mobileConfig{}); !errors.Is(err, errAlreadyRunning) { //nolint:lll // long test description t.Fatalf("startWithConfig(running) = %v", err) } resetMobileGlobals(t) @@ -173,7 +175,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 != "127.0.0.1:1080" || + cfg.RoomURL != testRoomID || cfg.DeviceID != "client" || cfg.LocalAddr != "127.0.0.1:1080" || cfg.DNSServer != defaultDNSServer || opts.FPS != 60 || opts.BatchSize != 8 || cfg.Liveness.Interval != 2500*time.Millisecond || cfg.Liveness.Timeout != 750*time.Millisecond || @@ -190,7 +192,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", testRoomID, "client", "key", 1080, "", ""); err != nil { t.Fatalf("StartWithTransport() error = %v", err) } if !IsRunning() { @@ -213,7 +215,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 != testRoomID || cfg.LocalAddr != "127.0.0.1:1081" || cfg.SOCKSUser != "u" || cfg.SOCKSPass != "p" || cfg.Liveness.Interval != control.DefaultInterval || cfg.Liveness.Timeout != control.DefaultTimeout || @@ -226,7 +228,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", testRoomID, "client", "key", 1081, "u", "p"); err != nil { t.Fatalf("Start() error = %v", err) } if err := WaitReady(100); err != nil { @@ -248,7 +250,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", testRoomID, "client", "key", 1082, 100, -1, 999) if err != nil { t.Fatalf("Check() error = %v", err) } @@ -272,7 +274,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", testRoomID, "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 { @@ -293,7 +295,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, testRoomID, "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) } @@ -301,7 +303,9 @@ 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, testRoomID, "client", "key", 1084, 100, 30, 1, + ); !errors.Is(err, want) { t.Fatalf("Check(run error) = %v, want %v", err, want) } }