config_json_test.go 477 B

123456789101112131415161718192021222324252627
  1. // +build json
  2. package blackhole_test
  3. import (
  4. "encoding/json"
  5. "testing"
  6. . "github.com/v2ray/v2ray-core/proxy/blackhole"
  7. "github.com/v2ray/v2ray-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. _, ok := config.Response.(*HTTPResponse)
  20. assert.Bool(ok).IsTrue()
  21. }