v2ray-core/proxy/blackhole/config_json_test.go

32 lines
594 B
Go
Raw Normal View History

2016-08-08 21:53:07 +00:00
// +build json
2016-07-24 11:40:27 +00:00
package blackhole_test
import (
"encoding/json"
"testing"
2016-08-20 18:55:45 +00:00
. "v2ray.com/core/proxy/blackhole"
"v2ray.com/core/testing/assert"
2016-07-24 11:40:27 +00:00
)
func TestHTTPResponseJSON(t *testing.T) {
assert := assert.On(t)
rawJson := `{
"response": {
"type": "http"
}
}`
config := new(Config)
err := json.Unmarshal([]byte(rawJson), config)
assert.Error(err).IsNil()
2016-09-22 10:01:36 +00:00
assert.Int(int(config.Response.Type)).Equals(int(Response_HTTP))
response, err := config.Response.GetInternalResponse()
assert.Error(err).IsNil()
_, ok := response.(*HTTPResponse)
2016-07-24 11:40:27 +00:00
assert.Bool(ok).IsTrue()
}