From 0db4e859c235ab3eeaa836a1513f48d75ef0ed19 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Thu, 25 Apr 2024 16:39:37 +0200 Subject: [PATCH] Add testcase for subscriber in different country but same continent. --- mcu_proxy_test.go | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/mcu_proxy_test.go b/mcu_proxy_test.go index 817e7b9..2e88f6c 100644 --- a/mcu_proxy_test.go +++ b/mcu_proxy_test.go @@ -1204,6 +1204,56 @@ func Test_ProxySubscriberCountry(t *testing.T) { } } +func Test_ProxySubscriberContinent(t *testing.T) { + CatchLogForTest(t) + t.Parallel() + serverDE := NewProxyServerForTest(t, "DE") + serverUS := NewProxyServerForTest(t, "US") + mcu := newMcuProxyForTestWithServers(t, []*TestProxyServerHandler{ + serverDE, + serverUS, + }) + + ctx, cancel := context.WithTimeout(context.Background(), testTimeout) + defer cancel() + + pubId := "the-publisher" + pubSid := "1234567890" + pubListener := &MockMcuListener{ + publicId: pubId + "-public", + } + pubInitiator := &MockMcuInitiator{ + country: "DE", + } + pub, err := mcu.NewPublisher(ctx, pubListener, pubId, pubSid, StreamTypeVideo, 0, MediaTypeVideo|MediaTypeAudio, pubInitiator) + if err != nil { + t.Fatal(err) + } + + defer pub.Close(context.Background()) + + if pub.(*mcuProxyPublisher).conn.rawUrl != serverDE.URL { + t.Errorf("expected server %s, go %s", serverDE.URL, pub.(*mcuProxyPublisher).conn.rawUrl) + } + + subListener := &MockMcuListener{ + publicId: "subscriber-public", + } + subInitiator := &MockMcuInitiator{ + country: "FR", + } + sub, err := mcu.NewSubscriber(ctx, subListener, pubId, StreamTypeVideo, subInitiator) + if err != nil { + t.Fatal(err) + } + + defer sub.Close(context.Background()) + + if sub.(*mcuProxySubscriber).conn.rawUrl != serverDE.URL { + t.Errorf("expected server %s, go %s", serverDE.URL, sub.(*mcuProxySubscriber).conn.rawUrl) + } +} + func Test_ProxySubscriberBandwidth(t *testing.T) { CatchLogForTest(t) t.Parallel()