@@ -553,6 +553,7 @@ func testRequestWithBody(t *testing.T, verb, path string) {
553
553
testRequestWithBodyQueryParams ,
554
554
testRequestWithBodyQueryParamsAndBody ,
555
555
testRequestWithBodyBinaryBody ,
556
+ testRequestWithBodyTransferEncoding ,
556
557
}
557
558
for _ , testFunc := range testFuncs {
558
559
testFunc := testFunc
@@ -1030,6 +1031,45 @@ func testRequestWithBodyQueryParamsAndBody(t *testing.T, verb, path string) {
1030
1031
}
1031
1032
}
1032
1033
1034
+ func testRequestWithBodyTransferEncoding (t * testing.T , verb string , path string ) {
1035
+ testCases := []struct {
1036
+ given string
1037
+ want string
1038
+ }{
1039
+ {"" , "" },
1040
+ {"identity" , "" },
1041
+ {"chunked" , "chunked" },
1042
+ }
1043
+ for _ , tc := range testCases {
1044
+ tc := tc
1045
+ t .Run ("transfer-encoding/" + tc .given , func (t * testing.T ) {
1046
+ t .Parallel ()
1047
+
1048
+ srv := httptest .NewServer (app )
1049
+ defer srv .Close ()
1050
+
1051
+ r , _ := http .NewRequest (verb , srv .URL + path , bytes .NewReader ([]byte ("{}" )))
1052
+ if tc .given != "" {
1053
+ r .TransferEncoding = []string {tc .given }
1054
+ }
1055
+
1056
+ httpResp , err := srv .Client ().Do (r )
1057
+ assertNilError (t , err )
1058
+ assertIntEqual (t , httpResp .StatusCode , http .StatusOK )
1059
+
1060
+ var resp * bodyResponse
1061
+ if err := json .NewDecoder (httpResp .Body ).Decode (& resp ); err != nil {
1062
+ t .Fatalf ("failed to unmarshal body from JSON: %s" , err )
1063
+ }
1064
+
1065
+ got := resp .Headers .Get ("Transfer-Encoding" )
1066
+ if got != tc .want {
1067
+ t .Errorf ("expected Transfer-Encoding %#v, got %#v" , tc .want , got )
1068
+ }
1069
+ })
1070
+ }
1071
+ }
1072
+
1033
1073
// TODO: implement and test more complex /status endpoint
1034
1074
func TestStatus (t * testing.T ) {
1035
1075
t .Parallel ()
0 commit comments