2015-10-31 09:08:09 -04:00
|
|
|
package json
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/v2ray/v2ray-core/proxy/common/config"
|
2015-12-02 09:27:18 -05:00
|
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
2015-10-31 09:08:09 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRegisterInboundConfig(t *testing.T) {
|
2015-12-02 09:27:18 -05:00
|
|
|
v2testing.Current(t)
|
2015-10-31 09:08:09 -04:00
|
|
|
initializeConfigCache()
|
|
|
|
|
|
|
|
protocol := "test_protocol"
|
|
|
|
creator := func() interface{} {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
err := RegisterInboundConnectionConfig(protocol, creator)
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
configObj := CreateConfig(protocol, config.TypeInbound)
|
|
|
|
assert.Bool(configObj.(bool)).IsTrue()
|
|
|
|
|
|
|
|
configObj = CreateConfig(protocol, config.TypeOutbound)
|
|
|
|
assert.Pointer(configObj).IsNil()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRegisterOutboundConfig(t *testing.T) {
|
2015-12-02 09:27:18 -05:00
|
|
|
v2testing.Current(t)
|
2015-10-31 09:08:09 -04:00
|
|
|
initializeConfigCache()
|
|
|
|
|
|
|
|
protocol := "test_protocol"
|
|
|
|
creator := func() interface{} {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
err := RegisterOutboundConnectionConfig(protocol, creator)
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
configObj := CreateConfig(protocol, config.TypeOutbound)
|
|
|
|
assert.Bool(configObj.(bool)).IsTrue()
|
|
|
|
|
|
|
|
configObj = CreateConfig(protocol, config.TypeInbound)
|
|
|
|
assert.Pointer(configObj).IsNil()
|
|
|
|
}
|