| 196 | }; |
| 197 | |
| 198 | TEST_P(CreateCreateStructStepTest, TestEmptyMessageCreation) { |
| 199 | ExecutionPath path; |
| 200 | |
| 201 | auto adapter = env_->legacy_type_registry.FindTypeAdapter( |
| 202 | "google.api.expr.runtime.TestMessage"); |
| 203 | ASSERT_TRUE(adapter.has_value() && adapter->mutation_apis() != nullptr); |
| 204 | |
| 205 | ASSERT_OK_AND_ASSIGN(auto maybe_type, |
| 206 | env_->type_registry.GetComposedTypeProvider().FindType( |
| 207 | "google.api.expr.runtime.TestMessage")); |
| 208 | ASSERT_TRUE(maybe_type.has_value()); |
| 209 | if (enable_recursive_planning()) { |
| 210 | auto step = |
| 211 | CreateDirectCreateStructStep("google.api.expr.runtime.TestMessage", |
| 212 | /*fields=*/{}, |
| 213 | /*deps=*/{}, |
| 214 | /*optional_indices=*/{}, |
| 215 | /*id=*/-1); |
| 216 | path.push_back( |
| 217 | std::make_unique<WrappedDirectStep>(std::move(step), /*id=*/-1)); |
| 218 | } else { |
| 219 | auto step = CreateCreateStructStep("google.api.expr.runtime.TestMessage", |
| 220 | /*fields=*/{}, |
| 221 | /*optional_indices=*/{}, |
| 222 | /*id=*/-1); |
| 223 | path.push_back(std::move(step)); |
| 224 | } |
| 225 | |
| 226 | cel::RuntimeOptions options; |
| 227 | if (enable_unknowns(), enable_recursive_planning()) { |
| 228 | options.unknown_processing = cel::UnknownProcessingOptions::kAttributeOnly; |
| 229 | } |
| 230 | CelExpressionFlatImpl cel_expr( |
| 231 | env_, |
| 232 | FlatExpression(std::move(path), /*comprehension_slot_count=*/0, |
| 233 | env_->type_registry.GetComposedTypeProvider(), options)); |
| 234 | Activation activation; |
| 235 | |
| 236 | ASSERT_OK_AND_ASSIGN(CelValue result, cel_expr.Evaluate(activation, &arena_)); |
| 237 | ASSERT_TRUE(result.IsMessage()) << result.DebugString(); |
| 238 | const Message* msg = result.MessageOrDie(); |
| 239 | ASSERT_THAT(msg, Not(IsNull())); |
| 240 | |
| 241 | ASSERT_EQ(msg->GetDescriptor()->full_name(), |
| 242 | "google.api.expr.runtime.TestMessage"); |
| 243 | } |
| 244 | |
| 245 | TEST(CreateCreateStructStepTest, TestMessageCreateError) { |
| 246 | absl_nonnull std::shared_ptr<const RuntimeEnv> env = NewTestingRuntimeEnv(); |
nothing calls this directly
no test coverage detected