blackhole_test.go 690 B

1234567891011121314151617181920212223242526272829303132333435
  1. package conf_test
  2. import (
  3. "github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
  4. "testing"
  5. "github.com/v2fly/v2ray-core/v4/common/serial"
  6. . "github.com/v2fly/v2ray-core/v4/infra/conf"
  7. "github.com/v2fly/v2ray-core/v4/proxy/blackhole"
  8. )
  9. func TestHTTPResponseJSON(t *testing.T) {
  10. creator := func() cfgcommon.Buildable {
  11. return new(BlackholeConfig)
  12. }
  13. runMultiTestCase(t, []TestCase{
  14. {
  15. Input: `{
  16. "response": {
  17. "type": "http"
  18. }
  19. }`,
  20. Parser: loadJSON(creator),
  21. Output: &blackhole.Config{
  22. Response: serial.ToTypedMessage(&blackhole.HTTPResponse{}),
  23. },
  24. },
  25. {
  26. Input: `{}`,
  27. Parser: loadJSON(creator),
  28. Output: &blackhole.Config{},
  29. },
  30. })
  31. }