| 221 | } |
| 222 | |
| 223 | Status RunCommand(const std::string& json_path, const std::string& arrow_path, |
| 224 | const std::string& command) { |
| 225 | // Make sure the required extension types are registered, as they will be |
| 226 | // referenced in test data. |
| 227 | ExtensionTypeGuard ext_guard({uuid(), dict_extension_type()}); |
| 228 | |
| 229 | if (json_path == "") { |
| 230 | return Status::Invalid("Must specify json file name"); |
| 231 | } |
| 232 | |
| 233 | if (arrow_path == "") { |
| 234 | return Status::Invalid("Must specify arrow file name"); |
| 235 | } |
| 236 | |
| 237 | auto file_exists = [](const char* path) { return std::ifstream(path).good(); }; |
| 238 | |
| 239 | if (command == "ARROW_TO_JSON") { |
| 240 | if (!file_exists(arrow_path.c_str())) { |
| 241 | return Status::Invalid("Input file does not exist"); |
| 242 | } |
| 243 | |
| 244 | return ConvertArrowToJson(arrow_path, json_path); |
| 245 | } else if (command == "JSON_TO_ARROW") { |
| 246 | if (!file_exists(json_path.c_str())) { |
| 247 | return Status::Invalid("Input file does not exist"); |
| 248 | } |
| 249 | |
| 250 | return ConvertJsonToArrow(json_path, arrow_path); |
| 251 | } else if (command == "VALIDATE") { |
| 252 | if (!file_exists(json_path.c_str())) { |
| 253 | return Status::Invalid("JSON file does not exist"); |
| 254 | } |
| 255 | |
| 256 | if (!file_exists(arrow_path.c_str())) { |
| 257 | return Status::Invalid("Arrow file does not exist"); |
| 258 | } |
| 259 | |
| 260 | return ValidateArrowVsJson(arrow_path, json_path); |
| 261 | } else { |
| 262 | return Status::Invalid("Unknown command: ", command); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | class TestJSONIntegration : public ::testing::Test { |
| 267 | public: |
no test coverage detected