1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-09 11:51:02 -05: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 := RegisterInboundConfig(protocol, creator)
2015-10-31 09:08:09 -04:00
assert.Error(err).IsNil()
2016-01-25 11:23:10 -05:00
configObj, err := CreateInboundConfig(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
2016-01-25 11:23:10 -05:00
configObj, err = CreateOutboundConfig(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 := RegisterOutboundConfig(protocol, creator)
2015-10-31 09:08:09 -04:00
assert.Error(err).IsNil()
2016-01-25 11:23:10 -05:00
configObj, err := CreateOutboundConfig(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
2016-01-25 11:23:10 -05:00
configObj, err = CreateInboundConfig(protocol, nil)
2015-10-31 09:08:09 -04:00
assert.Pointer(configObj).IsNil()
}