blackhole_test.go 805 B

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