|  | @@ -3,16 +3,13 @@
 | 
	
		
			
				|  |  |  package point_test
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import (
 | 
	
		
			
				|  |  | +	"encoding/json"
 | 
	
		
			
				|  |  | +	"os"
 | 
	
		
			
				|  |  |  	"path/filepath"
 | 
	
		
			
				|  |  |  	"testing"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	_ "github.com/v2ray/v2ray-core/app/router/rules"
 | 
	
		
			
				|  |  |  	netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
 | 
	
		
			
				|  |  | -	_ "github.com/v2ray/v2ray-core/proxy/dokodemo"
 | 
	
		
			
				|  |  | -	_ "github.com/v2ray/v2ray-core/proxy/freedom"
 | 
	
		
			
				|  |  | -	_ "github.com/v2ray/v2ray-core/proxy/socks"
 | 
	
		
			
				|  |  | -	_ "github.com/v2ray/v2ray-core/proxy/vmess/inbound"
 | 
	
		
			
				|  |  | -	_ "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
 | 
	
		
			
				|  |  |  	. "github.com/v2ray/v2ray-core/shell/point"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	v2testing "github.com/v2ray/v2ray-core/testing"
 | 
	
	
		
			
				|  | @@ -22,8 +19,8 @@ import (
 | 
	
		
			
				|  |  |  func TestClientSampleConfig(t *testing.T) {
 | 
	
		
			
				|  |  |  	v2testing.Current(t)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	// TODO: fix for Windows
 | 
	
		
			
				|  |  | -	baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
 | 
	
		
			
				|  |  | +	GOPATH := os.Getenv("GOPATH")
 | 
	
		
			
				|  |  | +	baseDir := filepath.Join(GOPATH, "src", "github.com", "v2ray", "v2ray-core", "release", "config")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
 | 
	
		
			
				|  |  |  	assert.Error(err).IsNil()
 | 
	
	
		
			
				|  | @@ -42,8 +39,8 @@ func TestClientSampleConfig(t *testing.T) {
 | 
	
		
			
				|  |  |  func TestServerSampleConfig(t *testing.T) {
 | 
	
		
			
				|  |  |  	v2testing.Current(t)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	// TODO: fix for Windows
 | 
	
		
			
				|  |  | -	baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
 | 
	
		
			
				|  |  | +	GOPATH := os.Getenv("GOPATH")
 | 
	
		
			
				|  |  | +	baseDir := filepath.Join(GOPATH, "src", "github.com", "v2ray", "v2ray-core", "release", "config")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
 | 
	
		
			
				|  |  |  	assert.Error(err).IsNil()
 | 
	
	
		
			
				|  | @@ -58,3 +55,23 @@ func TestServerSampleConfig(t *testing.T) {
 | 
	
		
			
				|  |  |  	assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("freedom")
 | 
	
		
			
				|  |  |  	assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +func TestDefaultValueOfRandomAllocation(t *testing.T) {
 | 
	
		
			
				|  |  | +	v2testing.Current(t)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	rawJson := `{
 | 
	
		
			
				|  |  | +    "protocol": "vmess",
 | 
	
		
			
				|  |  | +    "port": 1,
 | 
	
		
			
				|  |  | +    "settings": {},
 | 
	
		
			
				|  |  | +    "allocate": {
 | 
	
		
			
				|  |  | +      "strategy": "random"
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }`
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	inboundDetourConfig := new(InboundDetourConfig)
 | 
	
		
			
				|  |  | +	err := json.Unmarshal([]byte(rawJson), inboundDetourConfig)
 | 
	
		
			
				|  |  | +	assert.Error(err).IsNil()
 | 
	
		
			
				|  |  | +	assert.StringLiteral(inboundDetourConfig.Allocation.Strategy).Equals(AllocationStrategyRandom)
 | 
	
		
			
				|  |  | +	assert.Int(inboundDetourConfig.Allocation.Concurrency).Equals(3)
 | 
	
		
			
				|  |  | +	assert.Int(inboundDetourConfig.Allocation.Refresh).Equals(5)
 | 
	
		
			
				|  |  | +}
 |