config_cache_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package json
  2. import (
  3. "testing"
  4. "github.com/v2ray/v2ray-core/proxy/common/config"
  5. v2testing "github.com/v2ray/v2ray-core/testing"
  6. "github.com/v2ray/v2ray-core/testing/assert"
  7. )
  8. func TestRegisterInboundConfig(t *testing.T) {
  9. v2testing.Current(t)
  10. initializeConfigCache()
  11. protocol := "test_protocol"
  12. creator := func() interface{} {
  13. return true
  14. }
  15. err := RegisterInboundConnectionConfig(protocol, creator)
  16. assert.Error(err).IsNil()
  17. configObj := CreateConfig(protocol, config.TypeInbound)
  18. assert.Bool(configObj.(bool)).IsTrue()
  19. configObj = CreateConfig(protocol, config.TypeOutbound)
  20. assert.Pointer(configObj).IsNil()
  21. }
  22. func TestRegisterOutboundConfig(t *testing.T) {
  23. v2testing.Current(t)
  24. initializeConfigCache()
  25. protocol := "test_protocol"
  26. creator := func() interface{} {
  27. return true
  28. }
  29. err := RegisterOutboundConnectionConfig(protocol, creator)
  30. assert.Error(err).IsNil()
  31. configObj := CreateConfig(protocol, config.TypeOutbound)
  32. assert.Bool(configObj.(bool)).IsTrue()
  33. configObj = CreateConfig(protocol, config.TypeInbound)
  34. assert.Pointer(configObj).IsNil()
  35. }