config_json_test.go 594 B

12345678910111213141516171819202122232425262728293031
  1. // +build json
  2. package blackhole_test
  3. import (
  4. "encoding/json"
  5. "testing"
  6. . "v2ray.com/core/proxy/blackhole"
  7. "v2ray.com/core/testing/assert"
  8. )
  9. func TestHTTPResponseJSON(t *testing.T) {
  10. assert := assert.On(t)
  11. rawJson := `{
  12. "response": {
  13. "type": "http"
  14. }
  15. }`
  16. config := new(Config)
  17. err := json.Unmarshal([]byte(rawJson), config)
  18. assert.Error(err).IsNil()
  19. assert.Int(int(config.Response.Type)).Equals(int(Response_HTTP))
  20. response, err := config.Response.GetInternalResponse()
  21. assert.Error(err).IsNil()
  22. _, ok := response.(*HTTPResponse)
  23. assert.Bool(ok).IsTrue()
  24. }