|
|
|
@ -9,29 +9,34 @@ import ( |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func TestProtoPath(t *testing.T) { |
|
|
|
|
url := EncodeURL("http://helloworld.Greeter/helloworld/{name}/sub/{sub.name}", &binding.HelloRequest{Name: "test", Sub: &binding.Sub{Name: "2233!!!"}}, false) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
url := EncodeURL("http://helloworld.Greeter/helloworld/{name}/sub/{sub.naming}", &binding.HelloRequest{ |
|
|
|
|
Name: "test", Sub: &binding.Sub{Name: "2233!!!"}, |
|
|
|
|
}, false) |
|
|
|
|
if url != `http://helloworld.Greeter/helloworld/test/sub/2233!!!` { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{name}/sub/{sub.name}", nil, false) |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{name}/sub/{sub.naming}", nil, false) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
if url != "http://helloworld.Greeter/helloworld/{name}/sub/{sub.name}" { |
|
|
|
|
if url != "http://helloworld.Greeter/helloworld/{name}/sub/{sub.naming}" { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{}/sub/{sub.name}", &binding.HelloRequest{Name: "test", Sub: &binding.Sub{Name: "hello"}}, false) |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{}/sub/{sub.naming}", &binding.HelloRequest{ |
|
|
|
|
Name: "test", Sub: &binding.Sub{Name: "hello"}, |
|
|
|
|
}, false) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
if url != "http://helloworld.Greeter/helloworld/{}/sub/hello" { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{}/sub/{sub.name.cc}", &binding.HelloRequest{Name: "test", Sub: &binding.Sub{Name: "hello"}}, false) |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{}/sub/{sub.name.cc}", &binding.HelloRequest{ |
|
|
|
|
Name: "test", Sub: &binding.Sub{Name: "hello"}, |
|
|
|
|
}, false) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
if url != "http://helloworld.Greeter/helloworld/{}/sub/{sub.name.cc}" { |
|
|
|
|
if url != "http://helloworld.Greeter/helloworld/{}/sub/" { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
url = EncodeURL( |
|
|
|
|
"http://helloworld.Greeter/helloworld/{}/sub/{test_repeated.1}", |
|
|
|
|
"http://helloworld.Greeter/helloworld/{}/sub/{test_repeated}", |
|
|
|
|
&binding.HelloRequest{ |
|
|
|
|
Name: "test", Sub: &binding.Sub{Name: "hello"}, |
|
|
|
|
TestRepeated: []string{"123", "456"}, |
|
|
|
@ -39,17 +44,21 @@ func TestProtoPath(t *testing.T) { |
|
|
|
|
false, |
|
|
|
|
) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
if url != "http://helloworld.Greeter/helloworld/{}/sub/{test_repeated.1}" { |
|
|
|
|
if url != "http://helloworld.Greeter/helloworld/{}/sub/123" { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{name}/sub/{sub.naming}", &binding.HelloRequest{Name: "test", Sub: &binding.Sub{Name: "5566!!!"}}, false) |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{name}/sub/{sub.naming}", &binding.HelloRequest{ |
|
|
|
|
Name: "test", Sub: &binding.Sub{Name: "5566!!!"}, |
|
|
|
|
}, false) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
if url != `http://helloworld.Greeter/helloworld/test/sub/5566!!!` { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/sub", &binding.HelloRequest{Name: "test", Sub: &binding.Sub{Name: "2233!!!"}}, false) |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/sub", &binding.HelloRequest{ |
|
|
|
|
Name: "test", Sub: &binding.Sub{Name: "2233!!!"}, |
|
|
|
|
}, false) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
if url != `http://helloworld.Greeter/helloworld/sub` { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
@ -61,9 +70,9 @@ func TestProtoPath(t *testing.T) { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{name}/sub/{sub.name33}", &binding.HelloRequest{Name: "test"}, false) |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/{name}/sub/{sub.name}", &binding.HelloRequest{Name: "test"}, false) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
if url != `http://helloworld.Greeter/helloworld/test/sub/{sub.name33}` { |
|
|
|
|
if url != `http://helloworld.Greeter/helloworld/test/sub/` { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -76,12 +85,12 @@ func TestProtoPath(t *testing.T) { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/sub/{sub.name}", &binding.HelloRequest{ |
|
|
|
|
url = EncodeURL("http://helloworld.Greeter/helloworld/sub/{sub.naming}", &binding.HelloRequest{ |
|
|
|
|
Sub: &binding.Sub{Name: "kratos"}, |
|
|
|
|
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"name", "sub.name"}}, |
|
|
|
|
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"name", "sub.naming"}}, |
|
|
|
|
}, false) |
|
|
|
|
fmt.Println(url) |
|
|
|
|
if url != `http://helloworld.Greeter/helloworld/sub/kratos?updateMask=name,sub.name` { |
|
|
|
|
if url != `http://helloworld.Greeter/helloworld/sub/kratos?updateMask=name,sub.naming` { |
|
|
|
|
t.Fatalf("proto path not expected!actual: %s ", url) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|