@@ -103,6 +103,105 @@ TEST(InvocationResponseTest, constructor_based_failure)
103103 EXPECT_EQ (R"( {"custom":"error"})" , resp.get_payload ());
104104}
105105
106+ // --- runtime_response tests ---
107+
108+ TEST (RuntimeResponseTest, constructor_sets_all_fields)
109+ {
110+ runtime_response resp (" payload data" , " application/json" , " xray-trace-123" );
111+ EXPECT_EQ (" payload data" , resp.get_payload ());
112+ EXPECT_EQ (" application/json" , resp.get_content_type ());
113+ EXPECT_EQ (" xray-trace-123" , resp.get_xray_response ());
114+ }
115+
116+ TEST (RuntimeResponseTest, constructor_with_empty_fields)
117+ {
118+ runtime_response resp (" " , " " , " " );
119+ EXPECT_EQ (" " , resp.get_payload ());
120+ EXPECT_EQ (" " , resp.get_content_type ());
121+ EXPECT_EQ (" " , resp.get_xray_response ());
122+ }
123+
124+ TEST (RuntimeResponseTest, constructor_with_empty_xray)
125+ {
126+ runtime_response resp (" error body" , " application/json" , " " );
127+ EXPECT_EQ (" error body" , resp.get_payload ());
128+ EXPECT_EQ (" application/json" , resp.get_content_type ());
129+ EXPECT_EQ (" " , resp.get_xray_response ());
130+ }
131+
132+ TEST (RuntimeResponseTest, large_payload)
133+ {
134+ std::string large (10000 , ' x' );
135+ runtime_response resp (large, " text/plain" , " " );
136+ EXPECT_EQ (10000u , resp.get_payload ().size ());
137+ EXPECT_EQ (large, resp.get_payload ());
138+ }
139+
140+ TEST (RuntimeResponseTest, can_be_used_for_init_error)
141+ {
142+ runtime_response init_err (
143+ R"( {"errorMessage":"module not found","errorType":"ImportError"})" , " application/json" , " xray-cause-data" );
144+ EXPECT_EQ (" application/json" , init_err.get_content_type ());
145+ EXPECT_NE (std::string::npos, init_err.get_payload ().find (" module not found" ));
146+ EXPECT_EQ (" xray-cause-data" , init_err.get_xray_response ());
147+ }
148+
149+ // --- invocation_response inheritance tests ---
150+
151+ TEST (InvocationResponseInheritanceTest, is_a_runtime_response)
152+ {
153+ invocation_response resp (" payload" , " text/plain" , true , " xray" );
154+ runtime_response const & base = resp;
155+ EXPECT_EQ (" payload" , base.get_payload ());
156+ EXPECT_EQ (" text/plain" , base.get_content_type ());
157+ EXPECT_EQ (" xray" , base.get_xray_response ());
158+ }
159+
160+ TEST (InvocationResponseInheritanceTest, three_arg_constructor_has_empty_xray)
161+ {
162+ invocation_response resp (" data" , " text/html" , true );
163+ EXPECT_EQ (" data" , resp.get_payload ());
164+ EXPECT_EQ (" text/html" , resp.get_content_type ());
165+ EXPECT_EQ (" " , resp.get_xray_response ());
166+ EXPECT_TRUE (resp.is_success ());
167+ }
168+
169+ TEST (InvocationResponseInheritanceTest, four_arg_constructor_preserves_xray)
170+ {
171+ invocation_response resp (" err" , " application/json" , false , " xray-data" );
172+ EXPECT_EQ (" err" , resp.get_payload ());
173+ EXPECT_EQ (" application/json" , resp.get_content_type ());
174+ EXPECT_EQ (" xray-data" , resp.get_xray_response ());
175+ EXPECT_FALSE (resp.is_success ());
176+ }
177+
178+ TEST (InvocationResponseInheritanceTest, failure_with_xray_response)
179+ {
180+ auto resp = invocation_response::failure (" err msg" , " ErrType" , " xray-cause" );
181+ EXPECT_FALSE (resp.is_success ());
182+ EXPECT_EQ (" application/json" , resp.get_content_type ());
183+ EXPECT_EQ (" xray-cause" , resp.get_xray_response ());
184+ EXPECT_NE (std::string::npos, resp.get_payload ().find (" err msg" ));
185+ }
186+
187+ TEST (InvocationResponseInheritanceTest, success_has_empty_xray)
188+ {
189+ auto resp = invocation_response::success (" ok" , " text/plain" );
190+ EXPECT_TRUE (resp.is_success ());
191+ EXPECT_EQ (" " , resp.get_xray_response ());
192+ }
193+
194+ TEST (InvocationResponseInheritanceTest, can_pass_as_runtime_response_const_ref)
195+ {
196+ invocation_response resp (" body" , " application/json" , false , " xray-123" );
197+ auto check = [](runtime_response const & r) {
198+ EXPECT_EQ (" body" , r.get_payload ());
199+ EXPECT_EQ (" application/json" , r.get_content_type ());
200+ EXPECT_EQ (" xray-123" , r.get_xray_response ());
201+ };
202+ check (resp);
203+ }
204+
106205// --- http::response tests ---
107206
108207TEST (HttpResponseTest, add_and_retrieve_header)
0 commit comments