mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
|
)
|
|
|
|
func TestRegisterInboundConfig(t *testing.T) {
|
|
v2testing.Current(t)
|
|
initializeConfigCache()
|
|
|
|
protocol := "test_protocol"
|
|
creator := func([]byte) (interface{}, error) {
|
|
return true, nil
|
|
}
|
|
|
|
err := RegisterInboundConnectionConfig(protocol, creator)
|
|
assert.Error(err).IsNil()
|
|
|
|
configObj, err := CreateInboundConnectionConfig(protocol, nil)
|
|
assert.Bool(configObj.(bool)).IsTrue()
|
|
assert.Error(err).IsNil()
|
|
|
|
configObj, err = CreateOutboundConnectionConfig(protocol, nil)
|
|
assert.Pointer(configObj).IsNil()
|
|
}
|
|
|
|
func TestRegisterOutboundConfig(t *testing.T) {
|
|
v2testing.Current(t)
|
|
initializeConfigCache()
|
|
|
|
protocol := "test_protocol"
|
|
creator := func([]byte) (interface{}, error) {
|
|
return true, nil
|
|
}
|
|
|
|
err := RegisterOutboundConnectionConfig(protocol, creator)
|
|
assert.Error(err).IsNil()
|
|
|
|
configObj, err := CreateOutboundConnectionConfig(protocol, nil)
|
|
assert.Bool(configObj.(bool)).IsTrue()
|
|
assert.Error(err).IsNil()
|
|
|
|
configObj, err = CreateInboundConnectionConfig(protocol, nil)
|
|
assert.Pointer(configObj).IsNil()
|
|
}
|