(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestScriptMatchConfiguration(t *testing.T) { |
| 27 | t.Run("no merge", func(t *testing.T) { |
| 28 | confs := []ConfigurationItem{ |
| 29 | { |
| 30 | Match: must.Get(NewScriptMatch(`c.protocol > 5 && c.browser != "firefox"`)), |
| 31 | Configuration: &livekit.ClientConfiguration{ |
| 32 | ResumeConnection: livekit.ClientConfigSetting_ENABLED, |
| 33 | }, |
| 34 | }, |
| 35 | } |
| 36 | |
| 37 | cm := NewStaticClientConfigurationManager(confs) |
| 38 | |
| 39 | conf := cm.GetConfiguration(&livekit.ClientInfo{Protocol: 4}) |
| 40 | require.Nil(t, conf) |
| 41 | |
| 42 | conf = cm.GetConfiguration(&livekit.ClientInfo{Protocol: 6, Browser: "firefox"}) |
| 43 | require.Nil(t, conf) |
| 44 | |
| 45 | conf = cm.GetConfiguration(&livekit.ClientInfo{Protocol: 6, Browser: "chrome"}) |
| 46 | require.Equal(t, conf.ResumeConnection, livekit.ClientConfigSetting_ENABLED) |
| 47 | }) |
| 48 | |
| 49 | t.Run("merge", func(t *testing.T) { |
| 50 | confs := []ConfigurationItem{ |
| 51 | { |
| 52 | Match: must.Get(NewScriptMatch(`c.protocol > 5 && c.browser != "firefox"`)), |
| 53 | Configuration: &livekit.ClientConfiguration{ |
| 54 | ResumeConnection: livekit.ClientConfigSetting_ENABLED, |
| 55 | }, |
| 56 | Merge: true, |
| 57 | }, |
| 58 | { |
| 59 | Match: must.Get(NewScriptMatch(`c.sdk == "android"`)), |
| 60 | Configuration: &livekit.ClientConfiguration{ |
| 61 | Video: &livekit.VideoConfiguration{ |
| 62 | HardwareEncoder: livekit.ClientConfigSetting_DISABLED, |
| 63 | }, |
| 64 | }, |
| 65 | Merge: true, |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | cm := NewStaticClientConfigurationManager(confs) |
| 70 | |
| 71 | conf := cm.GetConfiguration(&livekit.ClientInfo{Protocol: 4}) |
| 72 | require.Nil(t, conf) |
| 73 | |
| 74 | conf = cm.GetConfiguration(&livekit.ClientInfo{Protocol: 6, Browser: "firefox"}) |
| 75 | require.Nil(t, conf) |
| 76 | |
| 77 | conf = cm.GetConfiguration(&livekit.ClientInfo{Protocol: 6, Browser: "chrome", Sdk: 3}) |
| 78 | require.Equal(t, conf.ResumeConnection, livekit.ClientConfigSetting_ENABLED) |
| 79 | require.Equal(t, conf.Video.HardwareEncoder, livekit.ClientConfigSetting_DISABLED) |
| 80 | }) |
| 81 | } |
| 82 | |
| 83 | func TestScriptMatch(t *testing.T) { |
nothing calls this directly
no test coverage detected