github.com/imannamdari/v2ray-core/v5@v5.0.5/infra/conf/v4/blackhole_test.go (about)

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