@@ -26,25 +26,17 @@ func TestNewResponse(t *testing.T) {
2626 }
2727
2828 // Test case for successful creation of Response
29- resp , err := NewResponse (httpResp , false )
29+ resp , err := NewResponse (httpResp )
3030 if err != nil {
3131 t .Errorf ("NewResponse() returned unexpected error: %v" , err )
3232 }
3333 if resp .StatusCode != http .StatusOK {
3434 t .Errorf ("NewResponse() returned response with unexpected status code: %d" , resp .StatusCode )
3535 }
3636
37- // Test case for DTO creation when forceDTO is true
38- resp , err = NewResponse (httpResp , true )
39- if err != nil {
40- t .Errorf ("NewResponse(forceDTO=true) returned unexpected error: %v" , err )
41- }
42- if resp .DTO == nil {
43- t .Error ("NewResponse(forceDTO=true) did not create DTO" )
44- }
45-
4637 // Test case for error in NewResponse
47- resp , err = NewResponse (httpResp , false )
38+ httpResp .Body = nil
39+ resp , err = NewResponse (httpResp )
4840 if err == nil {
4941 t .Error ("NewResponse() did not return expected error for HTTP client error" )
5042 }
@@ -89,20 +81,6 @@ func TestResponse_SetRequestHeader(t *testing.T) {
8981 }
9082}
9183
92- // TestResponse_SetRequestBodyData tests the SetRequestBodyData method of the Response struct.
93- func TestResponse_SetRequestBodyData (t * testing.T ) {
94- // Test case for setting request body data
95- reqBody := & strings.Reader {}
96- httpReq := & http.Request {
97- Body : io .NopCloser (reqBody ),
98- }
99- response := Response {}
100- response = response .setRequestBodyData (httpReq )
101- if response .RequestBody == nil {
102- t .Error ("Response SetRequestBodyData() did not set the request body data correctly" )
103- }
104- }
105-
10684// TestResponse_SetRequestURI tests the SetRequestURI method of the Response struct.
10785func TestResponse_SetRequestURI (t * testing.T ) {
10886 // Test case for setting request URI
@@ -136,21 +114,3 @@ func TestResponse_SetData(t *testing.T) {
136114 t .Error ("Response SetData() did not set the response data correctly" )
137115 }
138116}
139-
140- type TestDTO struct {
141- Key string `json:"key"`
142- }
143-
144- // TestResponse_SetDTO tests the SetDTO method of the Response struct.
145- func TestResponse_SetDTO (t * testing.T ) {
146- // Test case for setting DTO
147- response := Response {Header : NewHeader (), Data : []byte (`{"key": "value"}` ), DTO : & TestDTO {}}
148- response , err := response .setDTO (false )
149- if err != nil {
150- t .Errorf ("Response SetDTO() returned unexpected error: %v" , err )
151- }
152-
153- if response .DTO == nil {
154- t .Error ("Response SetDTO() did not set the DTO correctly" )
155- }
156- }
0 commit comments