2016-01-02 11:40:51 -05:00
|
|
|
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"
|
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"
|
2016-01-02 11:40:51 -05:00
|
|
|
creator := func([]byte) (interface{}, error) {
|
|
|
|
return true, nil
|
2015-10-31 09:08:09 -04:00
|
|
|
}
|
|
|
|
|
2016-01-25 11:19:09 -05: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()
|
2016-01-02 11:40:51 -05:00
|
|
|
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) {
|
2015-12-02 09:27:18 -05:00
|
|
|
v2testing.Current(t)
|
2015-10-31 09:08:09 -04:00
|
|
|
initializeConfigCache()
|
|
|
|
|
|
|
|
protocol := "test_protocol"
|
2016-01-02 11:40:51 -05:00
|
|
|
creator := func([]byte) (interface{}, error) {
|
|
|
|
return true, nil
|
2015-10-31 09:08:09 -04:00
|
|
|
}
|
|
|
|
|
2016-01-25 11:19:09 -05: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()
|
2016-01-02 11:40:51 -05:00
|
|
|
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()
|
|
|
|
}
|