github.com/xtls/xray-core@v1.8.12-0.20240518155711-3168d27b0bdb/infra/conf/blackhole_test.go (about)

     1  package conf_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/xtls/xray-core/common/serial"
     7  	. "github.com/xtls/xray-core/infra/conf"
     8  	"github.com/xtls/xray-core/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  }