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