1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-12 23:18:36 -04:00
v2fly/proxy/internal/config/config_cache_test.go

49 lines
1.1 KiB
Go
Raw Normal View History

package config
2015-10-31 09:08:09 -04:00
import (
"testing"
2015-12-02 10:26:11 -05:00
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
2015-10-31 09:08:09 -04:00
)
func TestRegisterInboundConfig(t *testing.T) {
v2testing.Current(t)
2015-10-31 09:08:09 -04:00
initializeConfigCache()
protocol := "test_protocol"
creator := func([]byte) (interface{}, error) {
return true, nil
2015-10-31 09:08:09 -04:00
}
err := RegisterInboundConnectionConfig(protocol, creator)
assert.Error(err).IsNil()
configObj, err := CreateInboundConnectionConfig(protocol, nil)
2015-10-31 09:08:09 -04:00
assert.Bool(configObj.(bool)).IsTrue()
assert.Error(err).IsNil()
2015-10-31 09:08:09 -04:00
configObj, err = CreateOutboundConnectionConfig(protocol, nil)
2015-10-31 09:08:09 -04:00
assert.Pointer(configObj).IsNil()
}
func TestRegisterOutboundConfig(t *testing.T) {
v2testing.Current(t)
2015-10-31 09:08:09 -04:00
initializeConfigCache()
protocol := "test_protocol"
creator := func([]byte) (interface{}, error) {
return true, nil
2015-10-31 09:08:09 -04:00
}
err := RegisterOutboundConnectionConfig(protocol, creator)
assert.Error(err).IsNil()
configObj, err := CreateOutboundConnectionConfig(protocol, nil)
2015-10-31 09:08:09 -04:00
assert.Bool(configObj.(bool)).IsTrue()
assert.Error(err).IsNil()
2015-10-31 09:08:09 -04:00
configObj, err = CreateInboundConnectionConfig(protocol, nil)
2015-10-31 09:08:09 -04:00
assert.Pointer(configObj).IsNil()
}