mirror of
https://github.com/pion/webrtc.git
synced 2025-10-21 06:09:31 +08:00
Improve API nil handling
Create struct with default values in NewAPI instead of doing nil checks later.
This commit is contained in:

committed by
Sean DuBois

parent
6ddddd8cea
commit
82b3ab583c
15
api_test.go
15
api_test.go
@@ -19,6 +19,10 @@ func TestNewAPI(t *testing.T) {
|
||||
if api.mediaEngine == nil {
|
||||
t.Error("Failed to init media engine")
|
||||
}
|
||||
|
||||
if api.interceptorRegistry == nil {
|
||||
t.Error("Failed to init interceptor registry")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewAPI_Options(t *testing.T) {
|
||||
@@ -40,3 +44,14 @@ func TestNewAPI_Options(t *testing.T) {
|
||||
t.Error("Failed to set media engine")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewAPI_OptionsDefaultize(t *testing.T) {
|
||||
api := NewAPI(
|
||||
WithMediaEngine(nil),
|
||||
WithInterceptorRegistry(nil),
|
||||
)
|
||||
|
||||
assert.NotNil(t, api.settingEngine)
|
||||
assert.NotNil(t, api.mediaEngine)
|
||||
assert.NotNil(t, api.interceptorRegistry)
|
||||
}
|
||||
|
Reference in New Issue
Block a user